问题
Can anyone please help me in understanding drawableStateChanged method of toggle button in android??? I wanted to know why exactly it is used for and how to implement it?? I found it on following link: http://developer.android.com/reference/android/widget/ToggleButton.html.
回答1:
from reading through the documentation which states:
This function is called whenever the state of the view changes in
such a way that it impacts the state of drawables being shown.
it seems that this function will be called by the framework whenever the component needs to be redrawn and you can override it to (for example) perform so application specific logic which you need to do when the component is redrawn, like manually drawing something over the top of the component, or changing the font or doing something which is not possible using the stock attributes.
This question has an example of how you might implement it.
来源:https://stackoverflow.com/questions/20933094/can-anyone-please-help-me-in-understanding-drawablestatechanged-method-of-togg