在动态添加radiobutton时若是想引入style需要
RadioButton button=new RadioButton(new ContextThemeWrapper(mcontext,R.style.sh_ShopRadioButtonStyle),null,0);
但是这样的话控件的宽度和高度都是自适应的,而且margin也没法定义所以定义方法为
public void addview(RadioGroup radioGroup)
{
int index=0;
for(String ss:getListsize())
{ RadioGroup.LayoutParams lp = new RadioGroup.LayoutParams(160,
50);
lp.setMargins(10, 0, 0, 0);
RadioButton button=new RadioButton(new ContextThemeWrapper(mcontext,R.style.sh_ShopRadioButtonStyle),null,0);
button.setId(index);
button.setText(ss);
radioGroup.addView(button,lp);
index++;
}
}
这样就可以实现了。