Skip to content Skip to sidebar Skip to footer

How To Get String From An Arraylist From A Gridview Onitemclick In A Fragment?

I'm trying to set up an onclick listener for a gridview. The gridview shows text and an image. When an item is clicked, I want it to get the text from that item and check it agains

Solution 1:

Use the position param and get the item at that position

 Item item= (Item) parent.getItemAtPosition(position);
 Stringname= item.name;

and you can move the below to separate .java file

publicclassItem 
  {
             String name;
             int drawableId;

            Item(String name, int drawableId)
            {
                this.name = name;
                this.drawableId = drawableId;
            }
   }

Post a Comment for "How To Get String From An Arraylist From A Gridview Onitemclick In A Fragment?"