In Listview onItemClick() listener is not working?
-
21-12-2019 - |
Question
I have added an onItemClick() listener to a listview. The listener is not working.
Here is the code I am working with:`
MyBaseAdapter ma= new MyBaseAdapter(context, myList);
lvDetail.setAdapter(ma);
lvDetail.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
ListData ld= myList.get(arg2);
String des=ld.getDescription();
Toast.makeText(context,"description"+des, Toast.LENGTH_LONG).show();
}
});
Solution
Since you are using custom adapter, please write listener inside getView of adapter on item of list and perform operation.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow