2011-08-18 58 views
0

我看過很多關於如何製作spinners的教程,但它們每頁只顯示一個。當我嘗試插入2時,第二個不起作用。我沒有以前的Android編程知識,所以也許我只是把第二個微調代碼放在錯誤的地方。我真的可以使用一些代碼示例的幫助。如何在Android的一個頁面上創建多個spinners?

我用盡5次,但我似乎無法在這裏發佈我的代碼,到目前爲止,但它只是一個微調簡單的代碼

謝謝!

編輯:來到這裏的答案:http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/Spinner1.html

+0

其實我剛琢磨出來,但不能似乎能夠刪除這個問題,對不起。 – Smints

+0

發佈您的答案,這將有助於他人同樣的問題,然後在幾天內將其標記爲正確的答案,歡迎來到SO :-) – Blundell

+0

Blundell我很想發佈代碼,但我不知道如何.. .yeah總共noob,但我發現並複製了以下代碼:http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/Spinner1.html – Smints

回答

0

試試這個佈局...

<?xml version="1.0" encoding="UTF-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/search_scrvw" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 

<ScrollView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:scrollbars="vertical"> 

    <TableLayout 
     android:id="@+id/search_table" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="50dip" 
     android:layout_marginLeft="50dip" > 

     <TableRow 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent"> 
      <TextView 
       android:text="Sex" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <Spinner 
       android:id="@+id/spnr_srch_sex" 
       android:layout_width="150dip" 
       android:layout_height="wrap_content" /> 

     </TableRow> 

     <TableRow 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent"> 
      <TextView 
       android:text="Age" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <Spinner 
       android:id="@+id/spnr_srch_age" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

     </TableRow> 

     <TableRow 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent"> 
      <TextView 
       android:text="Country" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <Spinner 
       android:id="@+id/spnr_srch_country" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

     </TableRow> 

     <Button 
      android:id="@+id/search" 
      android:text="Search" 
      android:layout_width="100dip" 
      android:layout_height="wrap_content" /> 


    </TableLayout> 


    </ScrollView> 
</LinearLayout> 
相關問題