Android Question How can I read from editText .db data rather than Spinner ?

Itila Tumer

Active Member
Licensed User
Longtime User
B4X:
If spnFirstName.SelectedIndex > 0 Then
        Query = Query & "FirstName = '" & spnFirstName.SelectedItem & "' "
    End If
SelectedFirstName = spnFirstName.SelectedIndex
B4X:
Query1 = "SELECT DISTINCT FirstName FROM persons"
    Curs = Denek.SQL1.ExecQuery(Query1)
    spnFirstName.Add("no filter")
    'we fill the Spinner with the data from the database
    For i = 0 To Curs.RowCount - 1
        Curs.Position = i
        spnFirstName.Add(Curs.GetString("FirstName"))
    Next
How can I convert spinner to EditText input filter?
 

klaus

Expert
Licensed User
Longtime User
What exactly do you want to do ?
In the code you are refering to (SQLiteLight2) the Spinner is filled only with names in the database that way you filter on existing names.
If you replace it by an EditText then you can have anything in there and get no results when you filter. I don't see the interest.

As an answer to your question, you can replace
Query = Query & "FirstName = '" & spnFirstName.SelectedItem & "' "
by
Query = Query & "FirstName = '" & edtFirstName.Text & "' "
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
there is a spinner for filter. but I wantto use edit text so I mean I would like to add myself forexample person ID into editText and after I clikc filter , I want it filter entered data. I hope I could explain
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Simply replace the Spinner by an EditText and in the query use the code I posted before.
But I still don't understand the logic why you want to use an EditText.
I would like to add myself for example person ID into editText and after I clikc filter
Do you think the user will filter on an ID ?
In this case you could define an EditText for the ID.
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
I was going to wrtie at the same tiime :) Ops! I get something Klaus, I think I forget to change ,now I success
Thank you
 
Upvote 0
Top