Android 在列表项上有单选按钮
我有一个Android 在列表项上有单选按钮,android,android-layout,android-intent,android-emulator,android-widget,Android,Android Layout,Android Intent,Android Emulator,Android Widget,我有一个列表视图: <ListView android:id="@+id/my_list" android:layout_width="fill_parent" android:layout_height="fill_parent" /> 列表视图的每个项目行的布局如下所示: <? Xml version = "1.0" encoding = "utf-8"?> <LinearLayout xml
列表视图
:
<ListView
android:id="@+id/my_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
列表视图的每个项目行的布局如下所示:
<? Xml version = "1.0" encoding = "utf-8"?>
<LinearLayout
xmlns: android = "http://schemas.android.com/apk/res/android"
android: orientation = "horizontal"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
>
<ImageView
android: id = "@+id/my_img"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: layout_gravity = "center_vertical"
/>
<TextView
android: id = "@+id/my_value"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: textColor = "@drawable/ black" />
</ LinearLayout>
如上所述,列表的每一行都由一个ImageView
和一个TextView
组成。现在,我想在文本视图
旁边有一个单选按钮,如何在我的案例中添加单选按钮?试试这个
<? 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 = "fill_parent"
>
<ImageView
android: id = "@+id/my_img"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android:layout_algnParentLeft="true"
android: layout_centerVertical = "true"
/>
<TextView
android: id = "@+id/my_value"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android:layout_toRightOf="@id/my_img"
android: textColor = "@drawable/ black" />
<RadioButton
android: id = "@+id/radio"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android:layout_toRightOf="@id/my_value" />
</ RelativeLayout>
使用Relativelayout
和添加文本视图的结尾
Vipin你能解释一下问题是什么吗?@robinhood Leem.fin在我的回答后编辑了他的问题,我不知道他为什么会给出xml,他问如何在文本视图前面添加收音机