Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中从一个单选组中选择多个单选按钮值获取数据并存储在数据库中_Android_Radio Button_Radio Group - Fatal编程技术网

如何在android中从一个单选组中选择多个单选按钮值获取数据并存储在数据库中

如何在android中从一个单选组中选择多个单选按钮值获取数据并存储在数据库中,android,radio-button,radio-group,Android,Radio Button,Radio Group,如何获取单选组中选定的多个单选按钮值的数据并存储在数据库中..我有一个列表视图,它正在生成多个单选组。 1.我有一个自定义列表视图和一个自定义布局。它有一个单选组和多个单选按钮 2.因此,当应用程序运行时,它会根据从数据库获取的数据生成多个无线组的列表 3.那么,如何从这个多无线电组获取数据。如果它是一个单一的无线电组,它就可以了。。通过使用 放射组=(放射组)findViewById(R.id.radio) int selectedId=radioGroup.getCheckedRadioBu

如何获取单选组中选定的多个单选按钮值的数据并存储在数据库中..我有一个列表视图,它正在生成多个单选组。

1.我有一个自定义列表视图和一个自定义布局。它有一个单选组和多个单选按钮

2.因此,当应用程序运行时,它会根据从数据库获取的数据生成多个无线组的列表

3.那么,如何从这个多无线电组获取数据。如果它是一个单一的无线电组,它就可以了。。通过使用

放射组=(放射组)findViewById(R.id.radio)

int selectedId=radioGroup.getCheckedRadioButtonId()

开关(选择EDID){ .................. ............ }

我已将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>


您可以选择存储方式。

谢谢……但如果我有一个无线组,您提供的就可以了。根据您的屏幕截图,您有3个无线组,因为您可以使用findViewById初始化3个无线组,并获得每个无线组的selectedId。放射组=(放射组)findViewById(R.id.radio);
radioGroup = (RadioGroup) findViewById(R.id.radio);

int selectedId = radioGroup.getCheckedRadioButtonId();

// find the radiobutton by returned id
radioButton = (RadioButton) findViewById(selectedId);

Toast.makeText(MyAndroidAppActivity.this,
    radioButton.getText(), Toast.LENGTH_SHORT).show();

radioButton.getText() --- Store this value in database as a String.