How to implement OnClickListener
on a ListAdapter
? My data is coming from sqlite. I want to show half of the data in the first activity and the reamining in the second activty using OnClickListener
in ListAdapter
.
Asked
Active
Viewed 1,262 times
0
3 Answers
0
You need to implement the AdapterView.OnItemClickListener
interface and call setOnItemClickListener(AdapterView.OnItemClickListener)
on your ListView
.
If you're using ListFragment
oder ListActivity
, you could also override their onListItemClick(ListView lv, View v, int position, long id)
method instead.

tynn
- 38,113
- 8
- 108
- 143
0
You should use set ItemClickListener on ListView with help of "setOnItemClickListener". If you want to catch clicks in adapter, it will be better to use RecyclerView. Example - https://stackoverflow.com/a/24933117/2687734
0
What about:
.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
adapter.get(position); //get your custom model
}
});

Alex
- 1
- 1