2017-08-02 92 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

好的。但它不是正确的选择? –