Spinner - how to retrieve the correct value and display it

stefanoa

Active Member
Licensed User
Longtime User
i need to record in table "events" the value retrieved from a spinner.

Ex. Spinner >>
ID 1 : Work
ID 2 : Familiy
etc.

in Activity_Create:
....
DBUtils.ExecuteSpinner(SQLEvents, "SELECT description FROM eventsType", Null, 0, eventsTypeSpinner)
eventsTypeSpinner_ItemClick(1, eventsTypeSpinner.GetItem(0))
eventsTypeSpinner.SelectedIndex = 0
....

In InsertRecord:
m.Put("IDeventstype", eventstypespinner.SelectedItem )
...
ListOfMaps.Add(m)
DBUtils.InsertMaps(SQLEvents, "Events", ListOfMaps)

In ReadRecord ??????
eventstypespinner.GetItem(Cursor.GetString("IDeventstype")) ?????

thanks
 

stefanoa

Active Member
Licensed User
Longtime User
i need to know the sintax to retrieve a field value from a table (es. eventstype.description) e put (display) it into spinner field (in the ReadRecord function).

for the other type i use, for ex.:
surnameEditText.text = "" & Cursor.GetString("surname")
and works correctly..

but for spinner type, what's the sintax? :confused:
eventstypespinner.text = (Cursor.GetString("IDeven tstype")) is incorrect.....
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
I don't know if this is what you are looking for, but it is from the app Family Meds on the Share Your Creations forum. You might want to download that app and look at it.

B4X:
Sub loadSpnr
'this loads spinner with names
spnrName.clear
nList.Clear
Cursor = SQL1.ExecQuery("SELECT * FROM main")
If Cursor.RowCount > 0 Then
For i = 0 To Cursor.RowCount - 1
Cursor.Position = i
nList.Add(Cursor.GetString("name"))'names put in list to run in duplicate check
Next
dupChk
For j = 0 To nList.Size - 1
spnrName.Add(nList.Get(j))
Next
spnrName_itemClick(0,spnrName.GetItem(0))
End If
Cursor.Close
End Sub
 
Upvote 0

stefanoa

Active Member
Licensed User
Longtime User
i cannot fix the problem :(

someone has a complete example for INSERT and READ/EDIT a field from db using a SPINNER?

the spinner must show the field "description" but the value to store in my table must be "ID"...

es.table: category
fields: 1) ID
2) Description

spinner must show description field (es. WORK, FRIENDS, etc.).
but when i select a row from spinner , in my table i have to store "ID" value..

:sign0163:
 
Upvote 0

PlayboyOKC

New Member
Licensed User
Longtime User
Has anyone found a solution to this yet? I'm fighting with this same issue...

Still searching the forums/examples/shared code, but not finding a neat working answer.
 
Upvote 0

raytronixsystems

Active Member
Licensed User
Longtime User
I have been having probs with Family Meds and am looking to fix the issue I found: You cannot Edit or Delete the very first row in the database without generating a beyond bounds exception. Any fixes for this problem?
 
Upvote 0
Top