2012-11-27 38 views
0

我目前有一個具有相對佈局的Android項目。在Android中的相對佈局上使用單選按鈕

我想讓用戶設置一個選項(出來一個很長的列表)。 環顧四周後,我注意到使用單選按鈕並在對話框中顯示它們的可能性,如here所述。 但我讀到了單線按鈕需要在線性佈局中使用的API。

是否有另一種讓用戶從列表中選擇某些東西的方法?例如一種選擇列表?

感謝您的任何幫助。我已經添加了我目前的佈局來澄清。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#FFFFCC" > 

    <Button 
     android:id="@+id/buttonExit" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:text="Exit" /> 

    <Button 
     android:id="@+id/buttonStart" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginTop="52dp" 
     android:text="Play" /> 

    <Button 
     android:id="@+id/buttonStop" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/buttonStart" 
     android:layout_marginTop="21dp" 
     android:text="Pause" /> 

    <Button 
     android:id="@+id/Continue" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/buttonStop" 
     android:layout_marginTop="16dp" 
     android:text="Continue" /> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/Continue" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="36dp" 
     android:text="Ready." 
     tools:context=".MainActivity" /> 


</RelativeLayout> 
+0

你有沒有consideer使用微調? – fiddler

+0

您可以輕鬆將'RadioGroup'包裝在'LinearLayout'中。 – jnthnjns

+0

@fiddler Spinner似乎是個不錯的主意。讓我試試看...對於優秀的Android佈局教程有什麼建議?現在看看谷歌和開發者網站。 – dorien

回答