2017-08-02 88 views
-3

我試圖在微調中設置提示在android中,通過動態添加數據在微調。首先,我用spinner.setPrompt(「分支列表」)但不能將其設置爲微調器。儘管我的這段代碼很爛。但仍然沒有完成。然後我用第二種方法如下:在Android中的微調提示在工作不起作用

我在這裏通過分享我的xml代碼,這是我用於設置提示的第二種方法。

MainActivity.xml

 <Spinner 
      android:layout_width="250dp" 
      android:layout_height="wrap_content" 
      android:id="@+id/branchSpinner" 
      android:spinnerMode="dropdown" 
      android:prompt="@string/Branch" 
      /> 

Stings.xml

<string name="Branch">Branch</string> 
+0

問題是slimier爲[https://stackoverflow.com/questions/867518/how-to-make-an-android-spinner-with-initial-text-select-one](https:// stackoverflow.com/questions/867518/how-to-make-an-android-spinner-with-initial-text-select-one) –

回答

0

你必須使用機器人:spinnerMode = 「對話框」如果u想用微調顯示提示。

  <Spinner 
      android:layout_width="250dp" 
      android:layout_height="wrap_content" 
      android:id="@+id/branchSpinner" 
      android:spinnerMode="dialog" 
      android:prompt="@string/Branch" 
      /> 
+0

但我不想它作爲Dialog.I想要如果沒有項目被選中然後它將在我的微調器中顯示提示文字,該文字在添加到微調器的我的數組列表中不可見。 –

+0

android:spinnerMode只能在對話模式下工作,不能在下拉模式下使用。 –

+0

好的。但它不是正確的選擇? –