I found from looking at the stack trace that only GridView (view).measure() gets called when I call myGrid.requestLayout() (see first code snippet) but never GridView(view).layout(). Is this a bug or how do I force layout to be done on my gridview? (I've tried myGrid.forceLayout()...)
Thanks, Rickard On 27 Aug, 16:01, RickardF <[email protected]> wrote: > Hi all, > I have agridViewwhere I want to be able to toggle the item icons > when clicking them. So, when I click an item it gets "selected" which > is indicated by, say, bitmap B and when I click it again it should be > "unselected" and the item changes back to bitmap A. > > The problem is that I cannot get the grid to redraw after I have > clicked one of the items so the clicked item never changes icon. I > have tried to call requestLayout() but for some reason it only results > in a two successive calls to the adaptor's getView(), both with > position zero regardless of which item I clicked. What am I missing > here? > > Here are some code snippets: > > > > ... > finalGridViewmyGrid = (GridView) findViewById(...); > ... > myGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() > { > @Override > public void onItemClick(AdapterView<?> parent, > View view, > int position, > long id) > { > // Toggle icon. > toggleIconState(position); > > myGrid.requestLayout(); > } > }); > > >>> From my adaptor class (The getIcon() returns one of two bitmaps depending > >>> on a state var. (selected/unselected)) > > �...@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); > } > > // Use this position's asset group icon as the image view > contents. > imageView.setImageBitmap(getIcon(position)); > return imageView; > } > > Any ideas are most welcome. > > 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 -~----------~----~----~----~------~----~------~--~---

