this application requires: first click will change image1 to image2 second click will change back to old image (image2 to image1)
image1 = (ImageView)findViewById(R.id.imageView1);
image1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
image1.setImageResource(R.drawable.a3_01);
image1.setTag(70);
}
});
this image will set a new tag for the server knows that the picture have been change.
*the code i used is only for the first click and it works. ive just have no idea to make a second click event. can anyone gives me idea of it? much appreciate. thanks.
You could use a boolean to act as a switch for you to flop back and forth with an if statement.
boolean showingFirst = true;
image1 = (ImageView)findViewById(R.id.imageView1);
image1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if(showingFirst == true){
image1.setImageResource(R.drawable.a3_02);
showingFirst = false;
}else{
image1.setImageResource(R.drawable.a3_01);
image1.setTag(70);
showingFirst = true;
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With