Android Question extrapolate from spinner to 3 edittext.

fifiddu70

Well-Known Member
Licensed User
Longtime User
hello everyone, I have a program with a spinner and EditText 3 1 for the name of a website, another for the user, another for your password in these EditText these data are inserted via a button and then memorize the all in one spinner through a dbsqilte, when I click on the spinner and I select one of the websites stored on EditText 3 must appear to be the name of the website, in the other edittetx the user, in the third EditText password, the problem I have and found that as soon as i enter a longer name on the first EditText, EditText in the user do not I see all the full numbers, see photos:

How can I always display correctly the user in the corresponding EditText?

B4X:
Sub splocale_ItemClick (Position As Int, Value As Object)
        txtutser.Text = splocale.SelectedItem
        Dim mk As Int
        mk= txtutser.Text.IndexOf("ID")
        txt1.Text=txtutser.Text.SubString2(mk + 3, txtutser.Text.Length)
        Dim kk As Int
        kk=txtutser.Text.IndexOf("PASS")
        txt2.Text=txtutser.Text.SubString2(kk + 5, txtutser.Text.Length)
        Dim DD As Int
        DD = txtutser.Text.IndexOf("ID")
        txt3.Text=txt1.Text.SubString2(DD - 5, txt1.Text.IndexOf("PASS"))
       
       
   
End Sub
 

Attachments

  • 1.png
    1.png
    26.6 KB · Views: 181
  • 2.png
    2.png
    28.2 KB · Views: 177

LucaMs

Expert
Licensed User
Longtime User
B4X:
        mk= txtutser.Text.IndexOf("ID")
        txt1.Text=txtutser.Text.SubString2(mk + 3, txtutser.Text.Length)

"ID" is 2 chars long, why you add 3?
and so on.

"ID" è lungo due caratteri, ma tu poi cerchi da mk+3. Tutto là. Anche nelle righe seguenti.


It is more convenient to use a split function (now I don't remember if it is in the StringFunctions library or StringUtils)

Better yet Regex, but it is more complex
 
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
The ID probably is:
B4X:
ID=txtutser.Text.SubString2(txtutser.Text.IndexOf("ID: ")+4, txtutser.Text.IndexOf("PASS: "))
 
Upvote 0
Top