Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 };
- notes = new SimpleCursorAdapter(this,
- R.layout.row, cursor, from, to);
- ListView view =getListView();
- view.setHeaderDividersEnabled(true);
- view.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
- view.setOnItemLongClickListener(new OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView<?> arg0, View view,
- int position, long arg3) {
- Toast.makeText(getApplicationContext(), "Hello"+position+" is clicked ",
- Toast.LENGTH_SHORT).show();
- return false;
- }
- });
- //setListAdapter(notes);
- setListAdapter(notes);
- class MyViewBinder implements SimpleAdapter.ViewBinder {
- public boolean setViewValue(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;
- }
- }
- Checkbox yourCheckbox = (Checkbox) view.findViewById(R.id.your_checkbox_id);
Add Comment
Please, Sign In to add comment