1

I am using listview in which each item (of list view) has a checkbox and a textview. when i am clivking on listview thw listener doesn't executes.

here is the code.

   ListView lv = (ListView) findViewById(R.id.list);

    final CustomListArrayAdaptor aa = new CustomListArrayAdaptor(this,data1);
    lv.setAdapter(aa);

    lv.setOnItemClickListener(new OnItemClickListener()
    {

        public void onItemClick(AdapterView<?> arg0, View v,int position, long arg3)
        {
            TextView tv=(TextView)v.findViewById(R.id.text);

            String s=tv.getText().toString();
            Toast.makeText(getApplicationContext(), "Item Selected :"+s,Toast.LENGTH_LONG).show();

        }
     });

It doesnt show the toast "Item Selected" when clicked on any item.

2 Answers2

1

This part of your code is correct. Upload the other files code also. As much I know this could be the problem of focus.Add (android:focusable="false") if you are defining the check box in xml file or for the java code use the method myCheckBox.setFocusable(false).

Om Narain Shukla
  • 361
  • 1
  • 4
  • 12
0

As explained here

Android custom ListView unable to click on items,

the click listener only works if no other view is focusable. Setting your CheckBox to focusable="false" should do the trick for you

Community
  • 1
  • 1
Avi Kumar
  • 4,403
  • 8
  • 36
  • 67