Is it possible to update my imageview with diffrent images within a specific time using timer or thread ?
setBackgroundResource() method is used to change the button background programmatically. setBackgroundResource(int id) accepts id of drawable resource and applies the background to the button.
drawable. my_image); imageView. setImageBitmap(bImage); Of course, this technique is only useful if you need to change the image.
You can make a view clickable, as a button, by adding the android:onClick attribute in the XML layout. For example, you can make an image act like a button by adding android:onClick to the ImageView .
An ImageView control is used to display images in Android applications. An image can be displayed by assigning it to the ImageView control and including the android:src attribute in the XML definition of the control.
ImageView image = (ImageView) findViewById(R.id.test_image);
image.setImageResource(R.drawable.xxx);
use the above code to set an image to the image view and use a thread that can change contents in the UI bascially some thing like this
public void onClick(View v) {
new Thread(new Runnable() {
public void run() {
ImageView image = (ImageView) findViewById(R.id.test_image);
image.setImageResource(R.drawable.xxx);
}
}).start();
}
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