I’m creating an Android app, when a user clicks a button in the app
the button image should change “to show it has been pressed” then some function is being called
using the following code at the onclick function:
{
btn.setBackgroundDrawable(getResources().getDrawable(R.drawable.sync_active));
sync();
}
what happens is the sync function is called first then the button image changes !!
All what you need is using the selectors in Android like this :
And in the
onClick()method ; you need just to call your functionsync(),refer this great tutorial it is exactly what you want 🙂