I am using selector to change color of button. And I was trying to do same with text property. Is it possible to change text in such way?
As far as I know, you can't do that because android:text="" takes string or string resource id as param. If you for example do something like this :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:text="SECOND" />
<item android:state_focused="true" android:state_pressed="true" android:text="SECOND" />
<item android:state_focused="false" android:state_pressed="true" android:text="SECOND" />
<item android:text="FIRST" />
</selector>
, like the way we are changing text color or background, it will put the path to this selector as your button text. It will be something like : res/drawable/text_selector.xml or whenever you put this file.
So the only way to achieve this is to control it manually in button's OnClickListener.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With