Wednesday, March 30, 2011

[android-developers] Changing ImageView's image

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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment