I simply need to change(toggle) the background colour of a textview
upon each touch.
So when a user first touches the textview, it turns blue. Upon the next touch it turns back to the default theme color for the textview. I have not specified any colours at all in any of the XML files so far.
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/list_item_name"
android:onClick="ToggleListItemSelectedState"/>
In the click handler for the textbox:
TextView selectedTextView = (TextView)view;
defaultBackground=//?How to save the default background
From this stackoverflow answer, I tried defaultBackground=selectedTextView.getBackground(); int colorCode = defaultBackground.getColor();
but the getColor()
isn't recognized.
I need to
Either get the default textview background colour from the theme
OR
Save the background colour the first time the textview is touched and then subsequently reset the background using the saved colour.
Thank you