comment remplacer/changer l'image du bouton par programmation android
J'ai une image de bouton sur mon point de vue qui j'ai besoin de changement après l'interaction de l'utilisateur. Je ne trouve rien comme myImageButton.setDrawable
Voici mon xml pour le bouton je veux changer:
<ImageButton
android:id="@+id/stopButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/buttons_background"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:background="@null"
android:src="@drawable/btn_play" />
La seule ligne que j'ai besoin de changer android:src="@drawable/btn_play"
à android:src="@drawable/btn_stop"
par programmation. Cela peut-il être fait? Merci à l'avance.
OriginalL'auteur madcoderz | 2013-05-13
Vous devez vous connecter pour publier un commentaire.
Vous pouvez utiliser
OriginalL'auteur Jithu
Utiliser ceci:
OriginalL'auteur James
OriginalL'auteur Celta
Utilisation
setImageResource(R.drawable.btn_stop);
OriginalL'auteur CSmith