简体   繁体   中英

Checkbox not clickable in simple listview

I have simple listview (Not custom listview) with checkbox in right side but these checkboxes are not clickable.

Here is my MainActivity.java Code:

setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, getResources().getStringArray(R.array.myarray)));

and here is xml code:

 <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
         >
    </ListView>

Also I need help to find out which checkbox was clicked on click of some button.

I have seen may questions posted on stackoverflow but they were all realeated to custom listview.

listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
listView.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, getResources().getStringArray(R.array.myarray)));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM