Android RadioButton class three kinds of checked way
2011-12-14 20:02
381 查看
The first : main.xml file,RadioButton element add android:checked attribute,
set "true";
The second : use setChecked() on the RadioButton from within your onCreate() callback in your activity.example:
RadioButton rb = (RadioButton)findViewById(R.id.radio1);
rb.setChecked(true);
The third:use check() on the RadioGroup from within your onCreate() callback in your activity.example:
RadioGroup rg = (RadioGroup)findViewById(R.id.radiogroup);
rg.check(R.id.radio2);
set "true";
The second : use setChecked() on the RadioButton from within your onCreate() callback in your activity.example:
RadioButton rb = (RadioButton)findViewById(R.id.radio1);
rb.setChecked(true);
The third:use check() on the RadioGroup from within your onCreate() callback in your activity.example:
RadioGroup rg = (RadioGroup)findViewById(R.id.radiogroup);
rg.check(R.id.radio2);
相关文章推荐
- how to put the text on the left of a radio button in android
- Android011之控件系列RadioButton
- android:clipChildren妙用:底部的radioGroup中间的button突出
- Android笔记:通过RadioGroup/RadioButton自定义tabhost的简单方法
- Android商城开发系列(三)——使用Fragment+RadioButton实现商城底部导航栏
- Android项目ViewPager+Fragment+RadioButton实现底部导航栏切换
- Android学习指南之九:Button、TextView、EditView、CheckBox、RadioGroup、ImageView、ImageButton
- ClassCastException: android.widget.Button cannot be cast to android.view.Vi
- android:button = @null in radiobutton
- Android 关于finish()、onDestory()、System.exit(0)、onCheckedChanged(RadioGroup arg0, int checkId)总结
- Android异常--Error inflating class android.support.design.widget.FloatingActionButton
- 【转】Find a way out of the ClassLoader maze (2)
- 未来IT行业将缩减到三类职业(The future of IT will be reduced to three kinds of jobs)
- android:clipChildren妙用:底部的radioGroup中间的button突出
- Android UI Radiobutton 样式
- RadioGroup中的RadioButton rb.setChecked(false)后重新选中无法选中——陈科肇
- 更改Android AppCompatRadioButton控件的样式和颜色
- Android控件系列之RadioButton&RadioGroup
- Android ListView 中加入CheckBox/RadioButton 选择状态保持、全选、反选实现
- Android控件系列之RadioButton&RadioGroup