java - Radio group not setting to radio buttons Android -
i fetching data database. based on value, i'm dynamically creating radio buttons. when try add radio group radio buttons, radio group not setting up. bcoz of can select many radio buttons @ once.
attr_layout[i].addview(radiobutton, lp); attr_layout[i]` value buttons im getting. values small, medium , large.
here complete code radiobutton.
radiogroup radiogroup = new radiogroup(mmain); linearlayout[] attr_layout = new linearlayout[optionslist.size()]; attr_layout[i] = new linearlayout(mmain); attr_layout[i].setorientation(linearlayout.horizontal); int attr_size = attributes.size(); (int k = 0; k < attr_size; k++) { string price = string.format(locale.english, appconstants.decimal_points, float.parsefloat(attributes.get(k).getattr_price())); string name_price = attributes.get(k).getattr_name() +" ("+ mmain.getstring(r.string.currency_code) +" "+ price +")"; if(!multiselect.equals("1")) // multiselect value 1 , 0 coming database. //based on these value, app display checkbox or radio button { final radiobutton radiobutton = new radiobutton(mmain); radiobutton.settext(name_price); radiobutton.setid(i + 6); radiobutton.settextsize(12); radiobutton.settag(attributes.get(k)); radiobutton.setgravity(gravity.start | gravity.center_vertical); if (build.version.sdk_int >= build.version_codes.jelly_bean_mr1) { radiobutton.settextalignment(view.text_alignment_view_start); } settextfont(radiobutton, "museo_slab.otf"); linearlayout.layoutparams lp = new linearlayout.layoutparams( linearlayout.layoutparams.match_parent, linearlayout.layoutparams.wrap_content, 1f); //lp.setmargins(10, 10, 0, 10); // llp.setmargins(left, top, right, bottom); radiogroup.layoutparams params = new radiogroup.layoutparams(radiogroup.layoutparams.wrap_content, radiogroup.layoutparams.wrap_content); radiogroup.setlayoutparams(params); attr_layout[i].addview(radiobutton, lp);`
add radiobuttons radio group add layouts.
use code
radiogroup.addview(radiobutton, lp); attr_layout[i].addview(radiogroup)
instead of
attr_layout[i].addview(radiobutton, lp);`
Comments
Post a Comment