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!
nk
Junior Developer
Junior Developer
 
Posts: 21
Joined: Tue Jan 29, 2008 3:23 pm

Top

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:
in CheckBoxifiedTextView.java
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.      public boolean getCheckBoxState(){
  2.          return mCheckBoxText.getChecked();
  3.      }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


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 1.0.8.4


Hope I could help you.

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

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 14 guests