
I have a listView that, through the ArrayAdapter, is populated with small xml submenus. each small view has only two things inside, a checkbox and a string label next to it.
I want to set the onCheckedChanged listener to capture a user event that checks or unchecks the checkboxes.
for example, the listener shown here:
listView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { Toast.makeText(this, "box has been checked", Toast.LENGTH_SHORT).show(); }
}
Where can I put the listener code? and how to configure it?
for ArrayAdapter:
public class MobileArrayAdapter extends ArrayAdapter<CheckBoxInfo>{ CheckBoxInfo[] objects; Context context; int textViewResourceId; public MobileArrayAdapter(Context context, int textViewResourceId, CheckBoxInfo[] objects) { super(context, textViewResourceId, objects); this.context = context; this.textViewResourceId = textViewResourceId; this.objects = objects; } @Override public View getView(int position, View convertView, ViewGroup parent) { View row_layout_view = convertView; if ((row_layout_view == null)){ LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); row_layout_view = inflater.inflate(R.layout.row_layout, null); }
source share