【发布时间】:2018-05-18 04:27:33
【问题描述】:
我是 android 中的新手,我无法获取从活动内片段上的 radiogroup 获取选定值的逻辑。 我想为我的班级做一个简单的提问者。
这是我的java
public class Frag3_Kepentingan extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view_frag3 = inflater.inflate(R.layout.activity_frag3_kepentingan, container, false);
return view_frag3;
我已经为每个单选按钮和单选组提供了 ID。 这是我的 xml_Layout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="290dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<TableRow
android:layout_width="match_parent"
android:layout_height="58dp">
<RadioGroup
android:id="@+id/grup31"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/grup31A1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:layout_weight="1" />
<RadioButton
android:id="@+id/grup31A2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:layout_weight="1" />
<RadioButton
android:id="@+id/grup31A3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:layout_weight="1" />
</RadioGroup>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true">
<Button
android:id="@+id/btnSimpanGrup3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:text="Simpan" />
</RelativeLayout>
</LinearLayout>
感谢您的分享。
【问题讨论】:
-
为片段中的无线电检查/取消检查创建获取和设置方法,现在在活动中访问这些方法!
标签: android android-fragments android-radiogroup