Problem with check box

Put your problem here if it does not fit any of the other categories.

Problem with check box

Postby nisha » Mon May 05, 2008 11:49 am

Hi All,

I am dynamically creating check boxes.. How to know which check box is selected (i.e clicked)?? If it was only one check box i can write like


checkbox.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
return;
}
});


I am having one check box but number of check boxes can be increased dynamically.. Then how to get which check box is selected? So that respective actions can be done...


regards and thanks,
nisha
nisha
Experienced Developer
Experienced Developer
 
Posts: 80
Joined: Fri Feb 15, 2008 7:52 am

Top

Postby nisha » Tue May 06, 2008 12:57 pm

Hi,

Can anybody help me out? ... Waiting for the reply...

regards & thanks,
nisha
nisha
Experienced Developer
Experienced Developer
 
Posts: 80
Joined: Fri Feb 15, 2008 7:52 am

Postby mathiastck » Tue May 06, 2008 8:39 pm

You can call setId(int id) on the checkbox. The listener gets the view as an argument, you can then call getId to get the id of the clicked checkbox, and take the appropriate action based on the id.
mathiastck
Freshman
Freshman
 
Posts: 6
Joined: Wed Feb 06, 2008 12:47 am

Postby nisha » Thu May 08, 2008 5:25 am

Hi,

Thanks a lot... I got it... :)


regards,
nisha
nisha
Experienced Developer
Experienced Developer
 
Posts: 80
Joined: Fri Feb 15, 2008 7:52 am

Postby hebbalhrk » Mon Jul 21, 2008 10:05 am

Hi Nisha,

Can u pls let me know how to know which textbox is being selected in dynamic checkbox list.

Also i have created a list of dynamic checkboxes in which i set the android contact as checkbox text, how do i retrieve the text of the checkbox on selection.

here's the code for the above discribed.
http://www.anddev.org/how_to_get_checkb ... t2571.html

Thanks
hebbalhrk
Developer
Developer
 
Posts: 37
Joined: Wed Jun 18, 2008 10:35 am

check box

Postby nisha » Mon Jul 21, 2008 10:16 am

Hi ,

You can setID for the check box you created.. And while retrieving u can use getId()..

regards,
nisha
nisha
Experienced Developer
Experienced Developer
 
Posts: 80
Joined: Fri Feb 15, 2008 7:52 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 16 guests