spinner with 2 colums

EddyW

Member
Licensed User
Longtime User
i get from a webservice a string like name1:Value1;name2:Value2;

is it posible to show in the spinner the values (value1, value 2 ) but when you select a value i get the name as return value.

In vb6 i would do it with a combobox with 2 colums and hide column1 (with the names) and show in column2 the values.
 

mangojack

Expert
Licensed User
Longtime User
EddieW ..

Can't find anything on the Spinner Control but for your info you can do exactly that with ListView.
I mimic VB Combobox with a label and adjoining ImageView containing a DownArrow.
Clicking Arrow shows / hides ListView.

B4X:
'using .AddTwoLines2 allows me to specify return value for click events...
lvwCombo.AddSingleLine2(Value1 & Value2, ReturnValue)
      
lvwCombo.AddTwoLines2(Value1 , Value2, ReturnValue)

Cheers mj

Edit .. Just found this , might be of interest
http://www.b4x.com/forum/basic4android-updates-questions/10546-spinner-text-value.html#post58711

Cheers mj
 
Last edited:
Upvote 0

EddyW

Member
Licensed User
Longtime User
Thanks Mangojack,

They want to use a spinner but the idea with a map could work.
Pitty that the spinner dont support multicolums.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Code below should work as long as your values do not contain commas. A better approach is to fill a list with your data and point to the chosen one, using the Position of spinner.
B4X:
Sub Globals
    Dim sp As Spinner 
End Sub

Sub Activity_Create(FirstTime As Boolean)
    sp.Initialize ("sp")
    sp.AddAll (Array As String ("name10,name11","name20,name22"))
    Activity.AddView (sp,0,0,60%x,15%y)
End Sub

Sub sp_ItemClick (Position As Int, Value As Object)
Dim rt() As String 
rt=Regex.Split (",",Value)
Msgbox(rt(0),"")
End Sub
 
Upvote 0

EddyW

Member
Licensed User
Longtime User
Thanks for the sugestion but dont think it would work for my situation because
i dont want to see the names only the values.

the sting i get from the webservices is name1:Value1;name2:Value2 and i cant change the webservices.

I solved it with a map object filling the spinner with the values and after spinner_selectedItem lookup in the map the Name.
 
Upvote 0
Top