AnZyuZya
AnZyuZya

Reputation: 213

Proper way to receive clicked item from GridView

What are the best practices of getting item from clicked cell in GridView?

Assume that GridView items (cells) are filled using BaseAdapter. And item contains of picture and text. How would you pass that unique clicked item to another activity?

Upvotes: 0

Views: 30

Answers (1)

czajna666
czajna666

Reputation: 587

Set listener:

 gridView.setOnItemClickListener(this);

and override this method:

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
   ... start your activity here ... (i stands for your clicked element)
}

Upvotes: 1

Related Questions