Go Android Custom Spinner (background, font color)

Source: Internet
Author: User

Android Custom Spinner (background, font color) (2012-07-04 17:04:44)  1, prepare two pictures, and do 9.png

2, defined in the drawableSpinner_selector.xml<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android "> <item android:state_pressed=" true "android:drawable=" @drawable/spinner_press "/><!--Press Time Effects-<item android:state_pressed= "false" android:drawable= "@drawable/spinner"/><!--default effect--&gt   ; </selector> 3, style definition <!--spinner---<style name= "Spinner_style"> <item name=" Android:background ">@drawable/spinner_selector</item> <item name= "Android:paddingleft" >5dip</item> </style> 4, call <spinner Android:id = "@+id/field_item_spinner_content" style= "@style/spinner_style"Android:layout_width=" fill_parent "android:layout_height=" Wrap_content "android:animationcache=" true "Androi D:drawselectorontop= "true"/> 5, defined in layoutSimple_spinner_item.xml<?xml version= "1.0" encoding= "Utf-8"? ><checkedtextview xmlns:android= "Http://schemas.android.com/apk/res /android "android:id=" @android: Id/text1 "android:paddingleft=" 5dip "android:paddingright=" 5dip "Android:gravi    Ty= "center_vertical" android:textcolor= "#808080" android:singleline= "true" android:layout_width= "Fill_parent" android:layout_height= "Wrap_content"/> 6, Java code arrayadapter<string> adapter = new arrayadapter<string& gt; (Mcontext,R.layout.simple_spinner_item); String level[] = getresources (). Getstringarray (R.array.affair_level);//resource file for (int i = 0; i < level.length; i++) {ADAP Ter.add (Level[i]);} Adapter.setdropdownviewresource (Android. R.layout.simple_spinner_dropdown_item); Spinner.setadapter (adapter);   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.