Onclicklistner not working in fragment listview

前端 未结 10 1286
不知归路
不知归路 2020-12-11 06:49

I have a listview with custom adapter in listfragment and also set onclicklistner for listview. But Onclicklistner does not work.

Here is my code:

p         


        
10条回答
  •  离开以前
    2020-12-11 07:02

    Check your MyCustomAdapter, Some widget (such as: Button,ImageButton) in the custom layout will consume the click event and then the onItemClick will never get called.

    Use the following code in your adaper's getView method to get the onClick event.

         row.setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View v) {
    
            }
        });
    

提交回复
热议问题