我的问题与this question类似,因为我无法找到一个令人满意的答案,我想明确提出我的问题。如何在自定义适配器中组单选按钮?
我有一个自定义的适配器,它需要一个字符串数组,并且必须使用该数组填充列表(在我的ListActivity类中定义)。现在,每行的布局有一个文本视图和一个单选按钮,如图
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:text="@+id/word"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/word"
android:textSize="30px">
</TextView>
<RadioButton
android:id="@+id/selection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4px"
android:layout_marginRight="10px"
android:layout_alignParentRight="true"
android:layout_x="27px"
android:layout_y="8px">
</RadioButton>
一切,直到这点工作的罚款。我能够用单选按钮呈现每一行。 我在寻找的是一种可以将这些单选按钮组合在一起执行单一选择的方法。 这是我正在制作的应用程序所需的,其中有四个选项作为答案。 也请告诉我这是否是这种问题的正确方法。 在此先感谢
看看我编辑的答案 – apesa 2011-04-01 00:45:53