Android GridView - update View based on position

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-02-07T17:10:20Z Indexed on 2010/03/08 11:51 UTC
Read the original article Hit count: 627

Filed under:
|

I have a GridView, using a custom adapter (myAdapter extends BaseAdapter), where each item in the grid holds an ImageButton. getView() is working fine.

However, from elsewhere in my code, how can I update the image (setImageResource) for one particular item in the grid based on its position in the GridView?

So far, I've added this to my adapter class:

public void changeImage() {
        Log.d(TAG, "Image change");
        this.ImageButton.setImageResource(R.drawable.newImage);
}

And would like to write something like this: mygridview.getItemIdAtPosition(20).changeImage(); (doesn't compile).

© Stack Overflow or respective owner

Related posts about android

Related posts about gridview