Roll over image of image button onClick of it
i am trying to change the image of my button as shown below.
else if (v == btnUt) {
Intent toUtilities = new Intent(City.this, UtilityScreen.class);
//btnUt is the name of my image button
btnUt.setBackgroundDrawable(getResources().getDrawable(R.drawable.mapicon));
}
Here the problem am facing is, it sets tow images for the same button, I want the previous image not to be shown when I reset new one for it.
Note: I do not want to use selectors instead pro-grammatically I am tr开发者_如何学Pythonying to achieve this.
Perhaps you have set the background drawable of the layout in which the button is located. Make sure that the layout in which the button is located, does not have a background drawable.
use this code for setting the ImageButton's image:
btnUt.setImageDrawable(getResources().getDrawable(R.drawable.mapicon));
精彩评论