I’m using the ListView to provide a list for the user to choose from.
Here is the main code:
SimpleAdapter adapter = new SimpleAdapter(this,contacts, R.layout.list_contact,
from_contacts, to_contacts);
listview_selected_contact.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
listview_selected_contact.setAdapter(adapter);
I wonder why the checkbox doesn’t show?
The program run properly just without the visible checkbox.
Can anyone help?
Here is the xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" android:textAppearance="?android:attr/textAppearanceMedium" android:id="@+id/username"></TextView>
</LinearLayout>
It looks like that your R.layout.list_contact isn’t CheckedTextView.
See source of android.R.layout.simple_list_item_multiple_choice
I can recommend you to build custom view which is child of any ViewGroup classes and implementator of interface Checkable.