码迷,mamicode.com
首页 > 其他好文 > 详细

======自定义Spinner======

时间:2015-01-30 10:47:54      阅读:99      评论:0      收藏:0      [点我收藏+]

标签: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

======自定义Spinner======

标签:android

原文地址:http://blog.csdn.net/soulofandroid/article/details/43303207

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!