मैं निम्नलिखित चयनकर्ता का उपयोग कर रहा हूं
text_selector.xml
& Lt;? Xml संस्करण = "1.0" एन्कोडिंग = "यूटीएफ -8"? & Gt; & Lt; चयनकर्ता xmlns: एंड्रॉइड = "http://schemas.android.com/apk/res/android" & gt; & Lt; आइटम एंड्रॉइड: state_selected = "true" android: color = "@ android: color / white" / & gt; & Lt; item android: state_focused = "true" एंड्रॉइड: color = "@ android: color / white" / & gt; & Lt; आइटम एंड्रॉइड: state_pressed = "true" android: color = "@ android: color / white" / & gt; & Lt; आइटम एंड्रॉइड: रंग = "@ एंड्रॉइड: रंग / काला" / & gt; & Lt; / चयनकर्ता & gt; मैं चयनकर्ता को रनटाइम पर सेट करने के लिए निम्न कोड का उपयोग कर रहा हूं
txtMainlabel.setTextColor (R.color.text_selector);
अपने चयनकर्ता को res / drawable के तहत रखें और
< कोड> label.setTextColor (। getResources () getColorStateList (R.drawable.text_selector)); android: clickable = "true" को सेट करने के लिए मत भूलें
Comments
Post a Comment