android - loading radiogroups from sqlite database -
i can't seem radiogroups populate based on below code. once cursor runs against database below output:
cursor data = db.getreadabledatabase().query(db.mytable, mycolumns, db.userid + "= ?", new string[]{string.valueof(user1)}, null, null, null); data.movetoposition(position); checkx = data.getint(data.getcolumnindex(db.value)); log.d("checkedid", "checkedid: " + checkx); 1 1 1 1 1
based on need first radiobutton checked each time. here current switch statement, nothing gets checked.
if(checkx > 0) { switch (checkx) { case 1: group.check(r.id.a1); break; case 2: group.check(r.id.a2); break; case 3: group.check(r.id.a3); break; case 4: group.check(r.id.a4); break; } }
programmatically, can use setchecked method defined in checkable interface:
if(checkx > 0) { switch (checkx) { case 1: radiobutton b1 = (radiobutton) findviewbyid(r.id.option1); b1.setchecked(true); break; case 2: radiobutton b2 = (radiobutton) findviewbyid(r.id.option2); b2.setchecked(true); break; --------- etc------------ }
Comments
Post a Comment