Customize android spinner

2019-05-28 23:17发布

问题:

I am trying to customize spinner. I found this tutorial, http://www.gersic.com/blog.php?id=57 It looks great but I am finding some errors all of which is like the following

 error: No resource identifier found for attribute 'state_dropdown_showing' in package 'android'

and the xml which leads to this error is

<!-- DROPDOWN SHOWING-->             
<item android:state_first="true"
      android:state_dropdown_showing="true" 
      android:drawable="@drawable/btn_dropdown_down"
      />    
<item android:state_middle="true" 
      android:state_dropdown_showing="true" 
      android:drawable="@drawable/btn_dropdown_up_down"
      />             
<item android:state_last="true"
      android:state_dropdown_showing="true"  
      android:drawable="@drawable/btn_dropdown_up"
      />   
<item android:state_single="true"
      android:state_dropdown_showing="true"  
      android:drawable="@drawable/btn_dropdown_neither_up_down"
      />                     

<!-- DROPDOWN NOT SHOWING-->

<item android:state_first="true"
      android:state_dropdown_showing="false" 
      android:drawable="@drawable/btn_dropdown_right_only"
      />    
<item android:state_middle="true" 
      android:state_dropdown_showing="false" 
      android:drawable="@drawable/btn_dropdown_left_right_collapsed"
      />             
<item android:state_last="true"
      android:state_dropdown_showing="false"  
      android:drawable="@drawable/btn_dropdown_left_only"
      />   
<item android:state_single="true"
      android:state_dropdown_showing="false"  
      android:drawable="@drawable/btn_dropdown_neither"
      />    

And I am not finding anything in the net relevant to this. I am at a fix now. I want to change the look and feel of the regular spinner with nice color background.

Anybody please guide me about customization of spinner.

回答1:

android:state_dropdown_showing it is worked on after r15 version only..so update the android sdk tools version.it is hopefully helpful to all