List item with CheckBox not clickable

前端 未结 9 1860
误落风尘
误落风尘 2020-12-31 01:12

I have a list item which contains a CheckBox, and I want to be able to click on the CheckBox and on the list item itself. Unfortunately, there seems to be some sort of confl

9条回答
  •  一整个雨季
    2020-12-31 01:52

    ok.. Make a CheckBox instance Like

    CheckBox check;
    check = (CheckBox) myView.findViewById(R.id.check);
    check.setOnClickListener(new CheckBoxSelect(position));
    

    put above code in onItemClickListener or in Adapter you are using. now make a class like below

    private class CheckBoxSelect implements OnClickListener 
        {
            int pos;
            String str;
    
            public CheckBoxSelect(int position) 
            {
                pos = position;
            }
    
            public void onClick(View v) 
            {
    
            }
    
        }
    

    perform any functionality in onClick .

提交回复
热议问题