首页 > 代码库 > ======自定义Spinner======
======自定义Spinner======
<?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
======自定义Spinner======
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。