CheckBox - how to see if its clicked or not?

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

CheckBox - how to see if its clicked or not?

Postby nk » Wed Jan 30, 2008 5:50 pm

Hi :)

just a simple (and also stupid) question: How can i react on a click
on a CheckBox? It seems like onListItemClick doesnt work but i want
to directly react on if a user clicks on one Checkbox in a List of
CheckBoxes. Which event is thrown when i change the state of a
CheckBox / when i click on it?

Thanks a lot in advance!
Junior Developer
Junior Developer
Posts: 21
Joined: Tue Jan 29, 2008 3:23 pm


Postby plusminus » Wed Jan 30, 2008 10:55 pm

Hello nk,

we have some code about a :src: CheckboxifiedTextList, you should find the appropriate snippets there.
You'll find a zip-file there which I corrected in the post following to that zip-file!

As it is not bluefloyd8 is not yet finished, you'll have to add some lines like:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.      public boolean getCheckBoxState(){
  2.          return mCheckBoxText.getChecked();
  3.      }
Parsed in 0.029 seconds, using GeSHi

Then something like this should be working in your MainListActivity (untested):
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         @Override
  2.         public void onListItemClick(ListView lv, View v, int i, long l){
  3.                 boolean checked = ((CheckBoxifiedTextView)v).getCheckBoxState();
  4.         }
Parsed in 0.031 seconds, using GeSHi

Hope I could help you.

Image | Android Development Community / Tutorials
User avatar
Site Admin
Site Admin
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany


Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot], Google Feedfetcher and 22 guests