last day (14 days later) » 

9:38 AM
1
A: Make a selected state for textview (highlighted)

user3249477You can do this programatically like this: findViewById(R.id.txt).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TextView textView = (TextView) v; if (textView.isSelected()) { textView.setTextColor(Color.RED); ...

 
I see, but I was asking if I press it and then it stays a different color until I press it again.
 
@XiJiaopin Well that's exactly what it does. It resets only when the activity is recreated.
 
Okay let me update with the edit
Is there any way to make it so that only one is selected at a time?
 
Would you have to deselect the first one to select another one? or should they switch?
 
Let's say TextView A is selected. when the textview b is touched then textview A automatically gets deselected and textview b is the only one selected.
 
9:38 AM
@XiJiaopin updated. Code will prevent more than 1 TextViews to be selected.
What's wrong?
 
Thanks for the help. just a question. Should previousView be put as a parameter because it cannot be resolved?
 
It should be a global variable like in my code
Outside of onCreate, but inside the Activity's class
 
Okay makes sense.
Looks right then
 
Glad you figured it out. Bye :-)
 
best answer :) and btw do you have any advice for performing a method while a textview is selected.

like psuedocode would be

if(H is selected)
then do this
if M selected
//do this
etc
just wondering if that's possible because in this case prev and current is used for the textviews
 

last day (14 days later) »