Android Studio 的 Spinner 設置方式與eclipse不太一樣
1. 在strings.xml 新增(建議用手打字):
< string name = " choose_chocolate " > Choose Chocolate
< string-array name = " chocolate " >
< item > Crackles < /item >
< item > Fruit and Nut < /item >
< item > Dairy milk silk < /item >
</string-array>
2. 在layout 檔裡新增:
< Spinner
android:id = " @+id/chocolate_spinner "
android:layout_height = " wrap_content "
android:layout_width = " fill_parent "
android:entries = " @array/chocolate "
android:prompt = " @string/choose_chocolate "
android:layout_toRightOf = " @+id/txtChoco "
android:layout_marginLeft = " 10dp "
android:layout_marginTop = " 15dp " />
全站熱搜
留言列表