0

I am facing some problem with ListView , I have inflated a layout with check box and used Custom base adapter.

I have used android:focusable="false" under check box in layout.

My ListView clicks works proper .But actually I want the respective check box to be checked on list-view click.

So,I can perform different functions on onLongclick or other.

Andro Selva
  • 53,910
  • 52
  • 193
  • 240
Arpit Garg
  • 8,476
  • 6
  • 34
  • 59

2 Answers2

4

Yuu can cast your view on

  lv.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view,
        int position, long id) {
            YourView yourView = (YourView)view;   
            Checkbox checkBox = (CheckBox)yourView.findViewById(R.id.yourcheckbox);

            checkBox.setChecked(true);
         }
     }    });
Mahadevan Sreenivasan
  • 1,144
  • 1
  • 9
  • 26
  • happy to help :) .. you can try to mark this answer as correct if you feel so :) – Mahadevan Sreenivasan Jun 15 '11 at 12:17
  • 1
    you don't need this line `YourView yourView = (YourView)view; ` onItemClickListener knows the current view(item) (in the paramaters) so this line `Checkbox checkBox = (CheckBox)yourView.findViewById(R.id.yourcheckbox);` become `Checkbox checkBox = (CheckBox)view.findViewById(R.id.yourcheckbox);` – Angie Dec 14 '11 at 15:15
1

may this help you....
1 2 3 4 5

Community
  • 1
  • 1
Android
  • 8,995
  • 9
  • 67
  • 108