ラジオ・グループで選択した複数のラジオ・ボタンの値を取得し、データベースに格納する方法。複数のラジオグループを生成しています。アンドロイドのラジオ・グループの複数のラジオ・ボタンの値を選択してデータベースに格納する方法
1.Iはit..whichためカスタムリストビューとカスタムレイアウトを持つ複数のラジオボタンを持つ単一のラジオ・グループを持っています。
2.Soを実行すると、データベースからフェッチしているデータに従って複数のラジオグループのリストが生成されます。
3.So、この複数のラジオグループからデータを取得する方法。その単一のラジオ・グループであれば、それを取得することができます。
radioGroup =(RadioGroup)findViewById(R.id.radio);
int selectedId = radioGroup.getCheckedRadioButtonId();
Swtich(selectedId){ .................. ............ }
Iが結合していますここでUI..below Here is the screenshot of the UI
はコードです: atten.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@color/white"
app:itemTextColor="@color/white"
app:menu="@menu/bott_menu" />
</RelativeLayout>
----- listCustomView.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/divider_color"
android:paddingBottom="0dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:background="@color/cpb_blue">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp"
tools:background="@color/cpb_red">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView"
android:layout_width="92dp"
android:layout_height="68dp"
android:src="@drawable/userprofile" />
<TextView
android:id="@+id/textViewrollno"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dp"
android:text="07"
android:textColor="@color/color_1" />
<TextView
android:id="@+id/textViewname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:gravity="right"
android:padding="10dp"
android:text=""
android:textSize="10dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioGroup
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal">
<CheckedTextView
android:id="@+id/checkedTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="CheckedTextView" />
<RadioButton
android:id="@+id/leave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="Leave" />
<RadioButton
android:id="@+id/late"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="Late" />
<RadioButton
android:id="@+id/absent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Absent" />
<RadioButtonl
android:id="@+id/present"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="present" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
ありがとう...しかし、あなたが提供しているものは、私が1つのラジオ・グループを持っていればOKです。 – egom
あなたのスクリーンショットによると、あなたは3つのラジオグループを初期化し、findViewByIdを使用して各ラジオグループの選択されたIDを取得できるので、3つのラジオグループを持っています。 radioGroup =(RadioGroup)findViewById(R.id.radio); – yash786
OKはそれを取得しようとします。 – egom