标签:android
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res/com.example.myviewdemo" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical" > <Spinner android:id="@+id/field_item_spinner_content" style="@style/spinner_style" android:layout_width="200dp" android:layout_height="wrap_content" android:animationCache="true" android:drawSelectorOnTop="true" android:dropDownSelector="@drawable/selector_spinner" android:spinnerMode="dropdown" /> </LinearLayout>
<style name="spinner_style"> <item name="android:background">@drawable/spinner_selector</item> </style>
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/spinner_drop_down_selected" android:state_pressed="true"/> <!-- 按下时效果 --> <item android:drawable="@drawable/spinner_drop_down_normal" android:state_pressed="false"/> <!-- 默认效果 --> </selector>
mSpinner = (Spinner) findViewById(R.id.field_item_spinner_content); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.simple_spinner_item, getResources().getStringArray(R.array.spinner_string_array)); mSpinner.setAdapter(adapter);http://www.cnblogs.com/coding-way/p/3549865.html
标签:android
原文地址:http://blog.csdn.net/soulofandroid/article/details/43303207