[android-developers] changing an image in a layout

2010-09-12 Thread dashman
i've got this simple layout in a file derived from Activity

?xml version=1.0 encoding=utf-8?
ScrollView
xmlns:android=http://schemas.android.com/apk/res/android;
android:layout_width=fill_parent
android:layout_height=fill_parent
android:padding=10dip 
ImageView android:id=@+id/photo
android:layout_width=wrap_content
android:layout_height=wrap_content /
/ScrollView

i'd like to change the imageview contents dynamically.

which method do i need to overload - again this class is derived
from Activity.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] changing an image in a layout

2010-09-12 Thread Kostya Vasilyev
 You don't need to override anything, but rather, whenever you want to 
change the image, do this:


- Get a reference to your ImageView:

ImageView photoImageView = (ImageView) findViewById(R.id.photo);

- Tell it to use a new image:

If it's a resource:

photoImageView.setImageResource(R.drawable.new drawable resource id here);

If the new image is a Drawable:

photoImageView.setImageDrawable(reference to a Drawable);

Or a bitmap:

photoImageView.setImageBitmap(reference to a Bitmap);

-- Kostya

13.09.2010 1:14, dashman пишет:

i've got this simple layout in a file derived from Activity

?xml version=1.0 encoding=utf-8?
ScrollView
xmlns:android=http://schemas.android.com/apk/res/android;
android:layout_width=fill_parent
android:layout_height=fill_parent
android:padding=10dip
ImageView android:id=@+id/photo
 android:layout_width=wrap_content
 android:layout_height=wrap_content /
/ScrollView

i'd like to change the imageview contents dynamically.

which method do i need to overload - again this class is derived
from Activity.




--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en