I have a:
public class MyList extends ListActivity {
SimpleAdapter simpleAdapter;
Binding to the ListView
is done by a ViewBinder
:
simpleAdapter = new SimpleAdapter(this, getData(path),
R.layout.menu_row, new String[] {
..., "checked" }, new int[] {..., R.id.checkBox1 });
SimpleAdapter.ViewBinder viewBinder = new SimpleAdapter.ViewBinder() {
@Override
public boolean setViewValue(View view, Object data,
String textRepresentation) {
if (view.getId() == R.id.checkBox1) {
CheckBox checkBox = (CheckBox) view;
checkBox.setChecked(Boolean.parseBoolean((String) data));
My xml looks like this, clickable
and focusable
helps that the row behaves seen as one.
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:clickable="false"
android:focusableInTouchMode="false"
/>
I also have a:
protected void onListItemClick(ListView l, View v, int position, long id) {
which interacts with the click event. This works good so far, my problem is
when I click on a row, the CheckBox
doesn't change its visual state. What can I do?
Put a
button.setChecked(true)
in you're onListItemClick ( or code to toggle back and forth using setChecked).EDIT
Misunderstood your issue. Have you told the adapter that the dataset has been changed?