Problem in CheckBoxifiedText

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

Problem in CheckBoxifiedText

Postby jagi » Thu Feb 07, 2008 2:34 pm

Hi All,

I am using the code which is provided in this site for the CheckBoxifiedText. I am facing some problem with this code as if insert more checkboxes ( i.e., more than screen fit 16 to 20 check box), then if i select any one of the check box and scroll down to the below checkbox , we found some of the checkbox is automatically get selected. How to avoid this.

Thanks,
jagi
jagi
Freshman
Freshman
 
Posts: 5
Joined: Thu Dec 06, 2007 9:54 am

Top

Postby plusminus » Fri Feb 08, 2008 5:32 pm

Hello jagi,

we also realized that. The first problem CheckBox is a View itself which consumes the Clicks and there for no ClickEvent is passed "down" to the onListItemClick() of the ListActivity. The second problem is that when you click the CheckBox it just looks like it got clicked (if you would try to get the State it would be the default you created it with) and if you scroll out once it gets "forgotten" and when it comes back a new checkbox-View is created with the default value.

This is a half-fix to the first Problem, it works fine with me:

Alter your Activity similar to this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         CheckBoxifiedTextListAdapter ctla;
  2.        
  3.         @Override
  4.         protected void onListItemClick(ListView l, View v, int position, long id) {
  5.                 ctla.toggleChecked(position);
  6.                 super.onListItemClick(l, v, position, id);
  7.         }
  8.  
  9.         @Override
  10.         public void onCreate(Bundle icicle) {
  11.                 super.onCreate(icicle);
  12.                 this.setContentView(R.layout.main);
  13.  
  14.                 ctla = new CheckBoxifiedTextListAdapter(this);
  15.                 // ....
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


In CheckboxifiedTextListAdapter add:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         public void toggleChecked(int position) {
  2.                 this.mItems.get(position).toggleChecked();
  3.         }
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


In CheckboxifiedText add:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         public void toggleChecked() {
  2.                 this.mChecked = !this.mChecked;
  3.         }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


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

Checkbox problem

Postby jagi » Mon Feb 11, 2008 6:58 am

Hi plusminus,

Thanks for the reply...
I have made use of your code which u have replied but still i am facing the same problem. Could u please help me to come out from this problem...

Regards,
Jagi
jagi
Freshman
Freshman
 
Posts: 5
Joined: Thu Dec 06, 2007 9:54 am

Postby nk » Fri Mar 14, 2008 4:15 pm

i have some problems with a list of checkboxes too - does anybody have a working example?
nk
Junior Developer
Junior Developer
 
Posts: 21
Joined: Tue Jan 29, 2008 3:23 pm

Top

Return to Other Coding-Problems

Who is online

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