I need to animate an icon of an arrow when opening and closing a spinner in Android.
I can rotate the arrow when opening the spinner: I just put a setOnTouchListener
on the Spinner
.
The problem comes, when the dropdown is closed, or hidden, because I don't know how to set a listener or something like that on that action.
Anybody has an idea about how to do this, if possible?
Thanks a lot in advance.
I do not know why Google can not do it for so long, but you can solve the problem this way:
You must override the protected method "onDetachedFromWindow" for Spinner, make it as public method, and calling forth it by clicking on the item in your CustomSpinnerAdapter.
For example:
I hope you know how to create SpinnerCustomAdapter and insert this CustomSpinner in xml.
You can do something like this,
try this way