我试图在android中设置Spinner的提示,然后在spinner中动态添加数据。首先,我使用了 spinner.setPrompt(" Branch List")但是没有& #39; t在微调器中设置它。虽然我的这行代码正在萎缩。但仍然没有完成它。然后我使用了第二种方法,如下:
我在这里分享我的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 :(得分:1)
如果你想使用微调器显示提示,你必须使用 android:spinnerMode =&#34;对话框&#34; 。
<Spinner
android:layout_width="250dp"
android:layout_height="wrap_content"
android:id="@+id/branchSpinner"
android:spinnerMode="dialog"
android:prompt="@string/Branch"
/>