Hi all,
I have a gridView where I want to eb able to "toggle" the item icons.
I.e when I click one of the items I want the cino to switch appearance
from, say bitmap A, to bitmap B. When I click it again it should
switch back to bitmap A.
I've got the logic in place but I cannot get the gridView to redraw
after I have handled the item click. I have tried with requestLayout()
but the only thing tht happens after clicking is that my adapter's
getView() gets called twice with position==0 regardless of which item
I clicked. The icon doesn't change.
What am I missing?
At startup the icons are nicely drawn so the getView() returns correct
imageViews.

Here are some code snippets:
>>
...
final GridView myGrid = (GridView) getViewById(...);

 assetGrid.setOnItemClickListener(new AdapterView.OnItemClickListener
()
        {
            @Override
            public void onItemClick(AdapterView<?> parent,
                    View view,
                    int position,
                    long id)
            {
                // Toggle icon
                toggleItemIcon(position);

               myGrid.requestLayout();
            }
        });

>> The getView() of my adapter. getItemIcon() returns a bitmap depending on 
>> what state the item is in.

 @Override
    public View getView(int position, View convertView, ViewGroup
parent)
    {
        ImageView imageView;

        if (convertView == null)
        {
            // Create the image view if we aren't recycling an old
view.
            imageView = new ImageView(context);
            imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        }
        else
        {
            imageView = (ImageView) (convertView);
        }

        imageView.setImageBitmap(getItemIcon(position));
        return imageView;
    }

Any ideas are much appreciated.

Thanks,
Rickard

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

Reply via email to