Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Multiple Checkboxes in ListView

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have made a list view using Custom Array Adapter.Each element in list view has checkbox inside.So there is more then one checkbox in entire list view. I want to know which checkboxes are clicked of which list item.


Please help .
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ Hardik

I think you should use relative layout in xml file in which you are creating list rows.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Step 1 : in the item (for example itemTwoLine) you use to create a list (for example mList)of item that you are passing to the adapter you add a field of type boolean ( for example cb1 ), in the item you add getter and setter for this property.

code of itemTwoLine :



Step 2 : in the adapter you add an on click listener on the checkbox of your layout :



step 3 : you populate a list of item and pass it to the adapter




and here are the code of the layout

item_two_line.xml :



itinerary.xml



main.xml



this sample code will provide you a list of item which contains an image, two line of text and a checkBox.
To retrieve state of checkboxs you can iterate to mListe in your mainActivity on the field cb1 with getCb1.
Then you will get for each line of mListe the state of the checkBox

hope this help

 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic