Que*_*ery 5 android unchecked radio-button
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rg"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.radiogroup.MainActivity" >
<RadioButton
android:id="@+id/rb_true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical" />
<RadioButton
android:id="@+id/rb_false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical" />
</RadioGroup>
Run Code Online (Sandbox Code Playgroud)
我有一个广播组,其中我有2个单选按钮
现在,如果选择单选按钮1,如果我点击相同的单选按钮(单选按钮1),则应该取消选中它.
它应该像切换一样工作.
使用以下方法以编程方式在警报框中显示单选按钮
Private void SelectLanguageMethod(){
// Strings to Show In Dialog with Radio Buttons
final CharSequence[] items = {"English"," Spanish "};
// Creating and Building the Dialog
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Select The Language");
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
//Your code here
}
});
levelDialog = builder.create();
levelDialog.show();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17133 次 |
| 最近记录: |