Hi, im with this task, i have 6 images and the user can click for change it, my actual code is:
how i can implement this to the 6 images? i have mypic1 to mypic6
I can create an array or how
thanks !
Code:
final ImageView mypic = findViewById(R.id.mypic1);
mypic.setTag(1);
mypic.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if(mypic.getTag().equals(1)){
mypic.setImageResource(R.drawable.pic1);
mypic.setTag(2);
}else{
mypic.setImageResource(R.drawable.pic2);
mypic.setTag(1);
}
} });
how i can implement this to the 6 images? i have mypic1 to mypic6
I can create an array or how

thanks !
Last edited by a moderator:
nClick
if you have 5 minutes please read this