Search code examples
androidandroid-gridviewandroid-event

Item not clicked on a GridView


I have a GridView whose items are ToggleButtons, and I defined an event listener for clicks on items, but nothing happens when I click on them. Here's the listener:

    paintActionsGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() 
    {
        public void onItemClick(AdapterView<?> parent,View view,int position,
                long id)
        { 
            ((ToggleButton)view).setChecked(true);
            paintBoardView.setPaintAction(paintActions[position]); 
        }
    });

I put a break point in the listener, but it's not reached, which means the listener is not called at all! Can somebody please tell me what's wrong? Is it related to the fact that the items are ToggleButtons? I can attach the adapter code if needed. Thanks.


Solution

  • The click event is consumed by ToggleButton hence not passed to the GridView. Similar to this post.