I'm trying to add a CheckBox to every item in my ListView. I can't put a CheckBox widget in the ListView, so how do I do it? I think the Android settings has something like this.
2 Answers
Off the top of my head, you should create an xml layout file representing an item in the ListView, in which you would declare a CheckBox. You can then set the adapter to use your layout for every item as follows:
ArrayAdapter<T> adapter = new ArrayAdapter<T>(this, R.layout.list_item, listReference);
setListAdapter(adapter);
setListAdapter is a method in ListActivity. Your list_item.xml should have the CheckBox defined in it.