Android ImageButton - determine what resource is currently set

Chris picture Chris · Jun 30, 2010 · Viewed 12.6k times · Source

Is there a way I can find what resource a particular ImageButton is set to, at any given time?

For eg: I have an ImageButton that I set to R.drawable.btn_on onCreate. Later, at some point, the ImageButton gets set to R.drawable.btn_off. I want to be able to check what resource the ImageButton is set to in my code.

Thanks Chris

Answer

CommonsWare picture CommonsWare · Jun 30, 2010

Just use setTag() and getTag() to associate and retrieve custom data for your ImageView.