Reputation: 35
So I'm using a custom view in on a List view and I'm tring to get the position of the view being clicked on, but I can't even get the debugger to display anything. I don't know what is wrong with this, any help would be appreciated.
ListAdapter BryceAdapter=new CustomAdapter(this,Restaurants,imgs);
ListView BryceListView=(ListView)findViewById(R.id.BryceListView);
BryceListView.setAdapter(BryceAdapter);
BryceListView.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.e(TAG, "onItemClick: ");
}
}
);
Upvotes: 1
Views: 23
Reputation: 90
You just need to add + position
like so:
ListAdapter BryceAdapter=new CustomAdapter(this,Restaurants,imgs);
ListView BryceListView=(ListView)findViewById(R.id.BryceListView);
BryceListView.setAdapter(BryceAdapter);
BryceListView.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.e(TAG, "onItemClick: " + postion);
}
}
);
Upvotes: 1