Friday, March 29, 2013

[android-developers] how to setImageResource for adjacent ImageView in onItemClick method

I've adapted the code from this android developer link to change an image when clicked on.  I would now like to know how i can change an adjacent image (or any other image in the gridview), by position index.  Thanks!


gridview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                ImageView imageView = (ImageView) v;
                imageView.setImageResource(R.drawable.image1);
               
                // TODO: set image at grid index position-1 (it is understood that boundary checking is required)
        }
});

--
--
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
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment