我有一个活动,我根据radiobutton
(内部放射组)的检查状态隐藏/取消隐藏一些布局和视图。
但是当我以编程方式检查radiobutton
时,checkedchangelistener
无效。但是当我手动检查radiobutton
时工作正常。
这是我的checkedChangeListener
:
ll - LinearLayout
edt - EditText
rg_listing.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.rb_auction:
listing_type = "auction";
ll_ps.setVisibility(View.GONE);
edt_startB.setVisibility(View.VISIBLE);
edt_resP.setVisibility(View.VISIBLE);
btn_startB.setVisibility(View.VISIBLE);
btn_resP.setVisibility(View.VISIBLE);
break;
case R.id.rb_fixedprice:
listing_type = "fixed price";
ll_ps.setVisibility(View.GONE);
edt_startB.setVisibility(View.GONE);
edt_resP.setVisibility(View.GONE);
btn_startB.setVisibility(View.GONE);
btn_resP.setVisibility(View.GONE);
break;
case R.id.rb_privatesale:
listing_type = "private sale";
ll_ps.setVisibility(View.VISIBLE);
edt_startB.setVisibility(View.GONE);
edt_resP.setVisibility(View.GONE);
btn_startB.setVisibility(View.GONE);
btn_resP.setVisibility(View.GONE);
break;
default:
System.out.println("Error in switch");
break;
}
}
}
);
我已尝试radiobutton.performClick()
,radiobutton.setChecked()
,radiogroup.check()
...
非常感谢任何帮助...... !!!