-1

我有一個ListView對列表項單選按鈕

<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> 

正如你看到的上面,每個行名單的ImageViewTextView組成。現在,我想在TextView旁邊有一個單選按鈕,如何在我的情況下添加單選按鈕?

+1

使用'Relativelayout'和'加Textview' – 2012-03-26 10:57:33

+0

的<單選/>到底是哪裏的問題? – Dharmendra 2012-03-29 10:51:04

回答

1

試試這個

<? 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> 
+1

Vipin你能解釋一下我們的問題是什麼? – RobinHood 2012-03-30 11:32:27

+0

@robinhood Leem.fin編輯他的問題後,我的答案不知道爲什麼 – vipin 2012-03-30 11:34:29

+1

他給了一個XML,他問如何在文本視圖前添加收音機 – vipin 2012-03-30 11:35:14