Android Question Customize spinner (drawable)

moster67

Expert
Licensed User
Longtime User
I am just wondering if it is possible to customize the look and feel of the spinner view?

I have experimented with the following code and noted I can set the spinner background (using a ninepatch image).

B4X:
Sub SetNinePatchDrawable(Control As View, ImageName As String)
    Dim r As Reflector
    Dim package As String
    Dim id As Int
    package = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
    id = r.GetStaticField(package & ".R$drawable", ImageName)
    r.Target = r.GetContext
    r.Target = r.RunMethod("getResources")
    Control.Background = r.RunMethod2("getDrawable", id, "java.lang.int")
   
End Sub

If possible, I would also like to change the Selector-image and also the background color of the list shown (I think it is called PopUpBackground). Is this possible? If yes, may I kindly ask for a code-example.

Here are some links I found which deal with customizing a spinner. It seems that various XML-files are involved.
http://www.gersic.com/blog.php?id=57

http://stephenpengilley.blogspot.it/2013/01/android-custom-spinner-tutorial.html

Thanks.
 

moster67

Expert
Licensed User
Longtime User
Thank you Roger for your LineLayout-library. I started playing around with it and it seems it might just do what I want and in addition it includes some other nice goodies. Nice library Roger. Thanks!

However, I am still interested in knowing how to replicate what mentioned in the links in my first post using B4A (if it is possible).
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…