Android Code Snippet SD: Spinner with CustomView


Licensed User
I've created a new class with CistomView to have the same features on the spinner object as ListView. A second line of text and the ability to add an image beside each item.

Also there is the ability to put the screen in gray when you click on the spinner. And finally, the ability to represent each item with rounded edges. In the cases there is an image that will also be rounded.

Hope it may be useful to you

Enabled As Boolean
SelectedItem As String
SelectedID As String
SelectedIndex As String
GrayDisplay As Boolean ' If Make Screeen gray when click (Set/Get)
BColor As Int ' BackgroundColor of Spinner's Label (Get/Set)
TColor As Int ' TextColor of Spinner's Label (Get/Set)
HintColor As Int ' TextColor of Spinner's Hint (Get/Set)
RoundCorner As Boolean
If the spinner opens in an anomalous position:
Set these prorpietes (left e Top) to set the screen position of the spinner's aperture on the screen.
For this reason we do not recommend inserting the spinner inside a scrollView because it has problems calculating its opening, or setting the position from code using left and top

Left As Int
Top As Int

Initialize (vCallback As Object, vEventName As String)
Add(Text As String, TextHelp As String,ID As String, BackgroundColor As Int, TextColor As Int, Gravities As Int,Image As Bitmap)
' Add Single element
AddAll(L As List, TextHelp As String, BackgroundColor As Int, TextColor As Int, Gravities As Int)
' Add a List
Size as int ' return number of elements
Clear ' Clear all elements
RemoveIndex(Position As Int) ' Remove element at Index
RemoveID(ID As String) ' Remove element from ID
GetItem(Position As Int) As String ' Get Value from position/index
GetItemFromID(ID As String) As String ' Get Value from ID
GetID(Position As Int) As String ' Get ID at position/index
SetIndex(Position As Int) ' Set selected from position/index
SetID(Id As String) ' Set selected from ID
SetBackgroundDrawable(Draw As ColorDrawable) ' Set Background with colordrawable
SetBackgroundImage(Bitmap As Bitmap) ' Set Background with image
SetLabelTextSize(TextSizeLabel As Int) ' Set Text Size of label
Close ' close a ListItem windows
Open ' Apen a ListItem Windows​

ItemClick (Position As Int, Value as String)​

Update 1.02
Screen1.png Screen2.png Screen3.png Screen4.png Screen5.png Screen6.png


Last edited:


Licensed User
Non ho capito
I do not understand. Please write in English
Last edited:

luciano deri

Active Member
Licensed User
In genere negli spinner, dopo che hai selezionato dalla lista, il contenuto della cella selezionata viene mostrato nello spinner chiuso a sinistra della freccia. Nell'esempio che ho scaricato il riquadro dello spinner rimane sempre vuoto.


Licensed User
Ho verificato e non mi da questo errore. In ogni caso nel prossimo Post manderò un aggiornamento della classe, fammi sapere se hai lo stesso problema
I checked and I did not make this mistake. Anyway in the next post I'll send an update to the class, let me know if you have the same problem
Last edited:

Johan Hormaza

Active Member
Licensed User
I have to see the code, the error says it is not initialized
I already solved the error, what happened was that I was loading it with a Panel.loadlayout, and that did not work. Thanks in advance.
By the way, this bookstore is great, my brother.

Johan Hormaza

Active Member
Licensed User
I have the Spinner in one position, but the panel that is displayed appears in another position.
What would be the problem?
Thank you


Licensed User
Sometimes if there are too many nested panels it can not find the absolute position.

On spinner you will find two porprieties that allow to correct this problem: Spinner.Left and Spinner.Top.

After you have hooked the Spinner in a panel, Assign Spinner.left and Spinner.Top the position you want it to appear on the screen and everything resolves.