Handling button event in each row of Listview issue

后端 未结 2 1746
滥情空心
滥情空心 2021-01-23 02:43

I am new to android and am trying to develop a new android app. But I am struggling to siolve one of the problems in my project.

I am using a listview extended from

2条回答
  •  无人共我
    2021-01-23 03:14

    I faced same type of problem. ListView's setOnItemClickListener not works if you add item like a button on every listView item. Solution is use onClick in the list Item layout(which you use in custom adapter file) as

    
    

    where onDeleteButtonClickListener is a method in the activity where you set the adapter in listview.

    public void onDeleteButtonClickListener(View v) {
    // your code
    }
    

    here listItem means the individual row item of a ListView


    Helpful Link: Button in ListView item

提交回复
热议问题