android studio get selected radio button
int radioButtonID = radioButtonGroup.getCheckedRadioButtonId();
View radioButton = radioButtonGroup.findViewById(radioButtonID);
int idx = radioButtonGroup.indexOfChild(radioButton);
android studio get selected radio button
int radioButtonID = radioButtonGroup.getCheckedRadioButtonId();
View radioButton = radioButtonGroup.findViewById(radioButtonID);
int idx = radioButtonGroup.indexOfChild(radioButton);
radio button android:inputType
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<RadioGroup
android:id="@+id/radioUnits"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:layout_width="match_parent"
android:layout_height="75dp"
android:text="@string/M"
android:id="@+id/M"
android:layout_gravity="center_horizontal"
android:checked="true" />
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/mM"
android:inputType="text"
android:id="@+id/mM"
android:layout_gravity="center_horizontal"/>
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/uM"
android:id="@+id/uM"
android:layout_gravity="center_horizontal"
android:layout_weight="0.09"/>
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/pM"
android:id="@+id/pM"
android:layout_gravity="center_horizontal"
android:layout_weight="0.09"/>
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/cM"
android:id="@+id/cM"
android:layout_gravity="center_horizontal"
android:layout_weight="0.09"/>
</RadioGroup>
<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Set"
android:layout_weight="0.15"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="68dp"
android:layout_marginBottom="133dp" />
<Button
android:id="@+id/b2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:layout_gravity="right"
android:layout_alignTop="@+id/b1"
android:layout_toRightOf="@+id/b1"
android:layout_toEndOf="@+id/b1"
android:layout_marginLeft="77dp" />
</RelativeLayout>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us