Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to update or change images of imageview dynamically in android?

Tags:

android

Is it possible to update my imageview with diffrent images within a specific time using timer or thread ?

like image 215
JCJ Avatar asked Jul 21 '11 06:07

JCJ


People also ask

Which method is used to change the ImageView background programmatically?

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.

Which file do you alter the image displayed by the ImageView in?

drawable. my_image); imageView. setImageBitmap(bImage); Of course, this technique is only useful if you need to change the image.

Can ImageView be clickable?

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 .

Which attribute is used to set an image in ImageView in android?

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.


1 Answers

    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();
}
like image 68
Abhay Kumar Avatar answered Oct 04 '22 21:10

Abhay Kumar