I have a textview, I set it as clickable and focusable – how do I get it to highlight to orange (like a button) when the user focuses it with the trackwheel etc?:
TextView tv = ...;
tv.setClickable(true);
tv.setFocusable(true);
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is quite easy. Here is the solution.
You have an TextView element with its background attribute set to
@drawable/tbselectorlike this.The last attribute
android:backgroundis essential the other stuff is up to you.Now you create a
tbselector.xmlin yourdrawablesubdirectory. Which looks like this.Now you create a
bgdefault.xmlin yourdrawablesubdirectory which looks like this.Finally create a
bgselected.xmlin yourdrawablesubdirectory which looks like the other one with other color values like this for example.And thats it you now have a state dependent TextView background. You can however decide to set your drawables in your selector XML it’s totally up to you. My values are just random values to show you the difference.
Hope it helps.