Re: [android-developers] Changing ImageView's image
On Wed, Mar 30, 2011 at 9:54 AM, Raghav Sood wrote: > Thanks. I have already tried that. The code I used was: > button.setImageResource(Drawable m1s.png); > > That didn't work. Is there something wrong or am i using the wrong part of > the api. > setImageResource() takes an image resource (e.g., R.drawable.my_image). -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9.2 Available! -- 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 ImageView's image
Hi Mark, Thanks. I have already tried that. The code I used was: button.setImageResource(Drawable m1s.png); That didn't work. Is there something wrong or am i using the wrong part of the api. On Wed, Mar 30, 2011 at 4:52 PM, Mark Murphy wrote: > setImageResource() or similar methods: > > http://developer.android.com/reference/android/widget/ImageView.html > > On Wed, Mar 30, 2011 at 7:01 AM, Raghav Sood wrote: > > Hi everyone, > > > > I have an ImageView who's image I need to chenge on touch.The ImageView's > > src is set through XML. My code is as follows: > > > > public class abc extends Activity { > > // Create an anonymous implementation of OnClickListener > > private OnClickListener match1 = new OnClickListener() { > > public void onClick(View v) { > > > > }; > > > > /** Called when the activity is first created. */ > > @Override > > public void onCreate(Bundle savedInstanceState) { > > super.onCreate(savedInstanceState); > > setContentView(R.layout.main); > > ImageView button = (ImageView)findViewById(R.id.l1m1); > > // Register the onClick listener with the implementation above > > button.setOnClickListener(match1); > > > > } > > > > > > } > > > > What do I put in the onclick event to change the ImageView's image? > > > > Thanks > > > > -- > > Raghav Sood > > http://www.raghavsood.com/ > > http://www.androidappcheck.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 > > > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://github.com/commonsguy > http://commonsware.com/blog | http://twitter.com/commonsguy > > _The Busy Coder's Guide to *Advanced* Android Development_ Version > 1.9.2 Available! > > -- > 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 -- Raghav Sood http://www.raghavsood.com/ http://www.androidappcheck.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
Re: [android-developers] Changing ImageView's image
setImageResource() or similar methods: http://developer.android.com/reference/android/widget/ImageView.html On Wed, Mar 30, 2011 at 7:01 AM, Raghav Sood wrote: > Hi everyone, > > I have an ImageView who's image I need to chenge on touch.The ImageView's > src is set through XML. My code is as follows: > > public class abc extends Activity { > // Create an anonymous implementation of OnClickListener > private OnClickListener match1 = new OnClickListener() { > public void onClick(View v) { > > }; > > /** Called when the activity is first created. */ > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > ImageView button = (ImageView)findViewById(R.id.l1m1); > // Register the onClick listener with the implementation above > button.setOnClickListener(match1); > > } > > > } > > What do I put in the onclick event to change the ImageView's image? > > Thanks > > -- > Raghav Sood > http://www.raghavsood.com/ > http://www.androidappcheck.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 -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9.2 Available! -- 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