Android Question spinner and EditExt

Isac

Active Member
Licensed User
I have included a spinner and a EditExt, with sql I populated the spinner with the numbers, now I want to populate the EditExt when the spinner visualize the number 1 then another text with the number 2 ... 3 ... 4
the text is found in the database.

example: select one from the spinner and EditExt capture from the database text ..... I select the number 2 from the spinner and EditExt capture another text from the database. Every number I associate it with a text written in the database.


B4X:
.......

.......

........

If Spinner1 = 1 Then


Edittext1.Text=dbsql.ExecQuery("SELECT eco FROM tav")

End If


thank you
 
Last edited:

Isac

Active Member
Licensed User
I would like to associate a number of spinner with a database column but I can not do it.
Example: If I select the spinner to 1 in the edit will be a column and row in the database ....
Does anyone have any example

Can anyone help me

B4X:
Sub spinner
dbcursor=dbsql.ExecQuery("SELECT Number FROM table")
For i = 0 To dbcursor.RowCount-1
DoEvents
dbcursor.Position=i
Spinner1.add(dbcursor.GetString("Error"))
Next
If Spinner1=1 then
ddcursor=dbsql.ExecQuery2("SELECT Solution FROM table WHERE Solution=?",Array As String("Solution1"))
For z = 0 To ddcursor.RowCount-1
DoEvents
ddcursor.Position=z
EditText1.Text=ddcursor.GetString("Solution")
Next
End If
dbcursor.Close
ddcursor.Close
End Sub
 

LucaMs

Expert
Licensed User
I would like to associate a number of spinner with a database column but I can not do it.
Example: If I select the spinner to 1 in the edit will be a column and row in the database ....
Does anyone have any example

Can anyone help me
B4X:
Sub FillErrorsSpinner
dbcursor=dbsql.ExecQuery("SELECT Number FROM table")
For i = 0 To dbcursor.RowCount-1
dbcursor.Position=i
spnErrors.add(dbcursor.GetString("Error"))
Next
dbcursor.Close
End Sub

Sub spnErrors_ItemClick (Position As Int, Value As Object)
ddcursor=dbsql.ExecQuery2("SELECT Solution FROM table WHERE Solution=?",Array As String(Value))
For z = 0 To ddcursor.RowCount-1
ddcursor.Position=z
EditText1.Text=ddcursor.GetString("Solution")
Next
ddcursor.Close
End Sub
If there is more than one solution for the error selected, you can not use an EditText to show them but a ListView, for example.
 

Mahares

Well Known Member
Licensed User
For cursor you use: dbcursor=dbsql.ExecQuery("SELECT Number FROM table")
But you populate the spinner with a different field:
spnErrors.add(dbcursor.GetString("Error"))
The 'Error' field is not part of the query. You need to use: "SELECT Error FROM table"
 

LucaMs

Expert
Licensed User
For cursor you use: dbcursor=dbsql.ExecQuery("SELECT Number FROM table")
But you populate the spinner with a different field:
spnErrors.add(dbcursor.GetString("Error"))
The 'Error' field is not part of the query. You need to use: "SELECT Error FROM table"
Ops, "maybe" this is right :D
 

Isac

Active Member
Licensed User
thanks, but when I press on the spinner and I select a number in the edit I see nothing

B4X:
Sub SpinnerP
dbcursor=dbsql.ExecQuery("SELECT Error FROM table")
For i = 0 To dbcursor.RowCount-1
dbcursor.Position=i
Spinner1.Add(dbcursor.GetString("Error"))
Next
dbcursor.Close
End Sub


Sub Spinner1_ItemClick(Position As Int, Value As Object)
Log ("POS :" & Position)
Log ("VAL :" & Value)
ddcursor=dbsql.ExecQuery2("SELECT Solution FROM table WHERE Solution=?",Array As String(Value))
For z = 0 To ddcursor.RowCount-1
ddcursor.Position=z
Log (ddcursor)
EditText1.Text=ddcursor.GetString("Solution")
Next
ddcursor.Close
End Sub
 
Last edited:

LucaMs

Expert
Licensed User
I don't know if you have a "Number" field in your db table.
If you have one "Error" field and a related "Solution"
the query should be:
B4X:
ddcursor=dbsql.ExecQuery2("SELECT Solution FROM table WHERE Error=?",Array As String(Value))
If not, please, post the structure of the table.
 
Top