• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Handling checkbox events with checkboxes created by CHOICE_MODE_MULTIPLE

icydash

Newbie
So, I've created a list with a bunch of items, each item having a checkbox next to it. I created the checkboxes simply by using: lv1.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

My problem is that when I click either the checkbox or the list item, it runs the same event: (something similar to below, it's not exact code)
lv1.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view,
int position, long id)
{
.....
}
}
});

What I would like to do is: make it so that when i click the text next to the check box (the list item), it runs the setOnItemClickListener event, but when you click the actual checkbox, it either checks (or unchecks) and runs a different event.

How can I do this? Thanks!!
 
It seems like a good amount of people have viewed this thread but no answers. Does nobody really know how to make clicking a checkbox not run the same event as clicking the list item next to it, or did I ask/word the question poorly?

Stated another way, I have something that looks like this:
list.jpg


The problem is that whether you click the word "Item #1," or the checkbox, it calls the same event (onItemClickListener) and does the same thing. But i only want it to call onItemClickListener if you click the text, NOT if you click the checkbox. When you click the checkbox, I just want it to act like a normal checkbox, and either be checked or not checked, or possibly call a different event.


In making the checkbox call its own even, it seems that part of the problem is: in order to make an event handler when the checkbox is clicked, I need to do something like this:

final CheckBox cb1Recup =(CheckBox) convertView.findViewById(R.id.cb1);
cb1Recup.setChecked(mListe.get(position).getCb1());
cb1Recup.setOnClickListener(new OnClickListener() {
....

However, to do that, you need to know that the id of the checkbox is "cb1", but with ListView.CHOICE_MODE_MULTIPLE I don't know what the ID's of the checkboxs are because they aren't made via an xml file.
 
Back
Top Bottom