开发者

Android: Custom spinner help

开发者 https://www.devze.com 2023-03-26 08:12 出处:网络
I am following this tutorial on how to create custom spinners. Near the begining it instructs you to navigate to: *android.jar\\res\\drawable-finger* But for some reason I can\'t find the \"drawable-f

I am following this tutorial on how to create custom spinners. Near the begining it instructs you to navigate to: *android.jar\res\drawable-finger* But for some reason I can't find the "drawable-finger开发者_运维百科" folder in my android.jar. I thought it may have to do with the API level so I changed it from 1.6 to 2.1 to no avail. I went around this and put them in the drawable folder thinking I could just work around it but then the spinner has the image stretched and malformed instead of repeating the image in the x direction. Any ideas?

Thanks!

EDIT: Here is the code Spinner

    <Spinner android:id="@+id/catspinner" android:layout_marginLeft="15dip" android:layout_marginRight="15dip"
 android:layout_width="fill_parent" android:layout_centerHorizontal="true"
 android:layout_height="wrap_content" android:layout_centerVertical="true"
 android:drawSelectorOnTop="true" android:background="@drawable/spinnerbackground"/>   

code for the spinner background:

    <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" 
          android:state_pressed="false" 
          android:drawable="@drawable/myspinner_select" />
    <item android:state_focused="true" 
          android:state_pressed="true"
          android:drawable="@drawable/myspinner_press" />
    <item android:state_focused="false" 
          android:state_pressed="true"
      android:drawable="@drawable/myspinner_press" />
    <item android:drawable="@drawable/myspinner_normal" />
</selector>

it looks like this

Android: Custom spinner help


Sherif is correct. As far as following the tutorial, it doesn't (and shouldn't) suggest that you put the images back in android.jar/res/drawable-finger. You should put your versions of those images in your drawable folders (i.e. drawable-ldpi, drawable-mdpi, etc).

I suspect that the issue with the image being stretched and not repeated is a result of your code or image, not the location you put the images. You could post your code and we might be able to help with that.

I also noticed that the tutorial looks like it is based off of a pre-release Android SDK version. I'm guessing that the drawable-finger folder no longer exists. It's also possible that other elements of the tutorial are outdated.

0

精彩评论

暂无评论...
验证码 换一张
取 消