How To Listen For A Checkbox In A Listview Row?
String[] from = new String[] { CallrzDbAdapter.C_NAME,CallrzDbAdapter.C_EMAIL,CallrzDbAdapter.C_PHONE }; int[] to = new int[] {R.id.cName, R.id.cEmail, R.id.cPhone }; not
Solution 1:
You can probably create your own ViewBinder and in setViewValue simply do something like:
classMyViewBinderimplementsSimpleAdapter.ViewBinder {
publicbooleansetViewValue(View view, Object data, String textRepresentation) {
int id = view.getId();
/* handle this particular item from our own view
if (id == R.id.myViewId) {
((CheckBox) view).setOnItemLongClickListener(...);
((CheckBox) view).setText(...);
return true;
}
return false;
}
}
You can thenjust use SampleAdapter for data and call
adapter.setViewBinder(new MyViewBinder());
Solution 2:
The view
from onItemLongClick
should contain your checkbox.
You can retreive it like you normally would:
CheckboxyourCheckbox= (Checkbox) view.findViewById(R.id.your_checkbox_id);
Correct me if i'm wrong, I normally use a Custom ArrayAdapter
EDIT:
You could look at this for an example.
Android Series: Custom ListView items and adapters
Hint: it's the getView
in the example where you can findViewById
your CheckBox
Post a Comment for "How To Listen For A Checkbox In A Listview Row?"