Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set default value checkbox android

i have data in database with value from checkbox
i try to set checkbox with value from database, if database not null checkbox checked but if null checkbox not checked..
my code like this:

public void load(){
   final Cursor c = helper.getSat(almagId);
       c.moveToFirst();
   if(c.getString(3) != null){
           ch1.isChecked();
   }
   isi2.setText(c.getString(4));
   if(c.getString(4) != null){
       ch2.isChecked();
   }
   isi3.setText(c.getString(5));
   if(c.getString(5) != null){
       ch3.isChecked();
   }
}

but it's not work..how can i solve this??thank you for feed back :)

like image 401
akubabas Avatar asked Dec 17 '22 01:12

akubabas


1 Answers

isChecked() will tell you if the CheckBox is checked or not; you cannot change the 'checked' value with this method.

In order to change it, use either setChecked(boolean) for an explicit value or toggle() to inverse it.

like image 177
MH. Avatar answered Jan 29 '23 12:01

MH.