java - dynamically selecting a radio button from a radio group -
i have stored previous selection of radio button in memory. when start activity has these radio buttons, show selected radio button selected. using java android studio. below copy of code:
public void getselectedunits() { if (symbol.equals("g")) { radio_g.check(r.id.radiobuttong); toast.maketext(settingsscreen.this, " grams(g) selected", toast.length_long).show(); } else if (symbol.equals("kg")) { radio_g.check(r.id.radiobuttonkg); toast.maketext(settingsscreen.this, " kilograms(g) selected", toast.length_long).show(); }
...
please note radio_g.check(r.id.radiobuttonx); statement crashes program, can idea trying accomplish. want set radio button selected during last visit activity selected. toast statements debugging , working fine.
solution used:
i got issue , able solve it, want update post in case reads in future. solution presented below, given other posts such as: how programmatically select radiobutton in activity
pounds = (radiobutton) findviewbyid(r.id.radiobuttonlb); if(devicecontrolactivity.symbol.equals("lb")) pounds.setchecked(true);
Comments
Post a Comment