Android Question Error trying to use edittext.requestfocus (String cannot be cast to android.view)

chrisinky

Member
Licensed User
Longtime User
I need to set my tab order manually. My program connects to a server and downloads it's screen definitions on the fly (and they change often, thousands of screens). So all edittexts are drawn on the fly.
I currently use the edittext.tag to store the field name given to the text box by the server so that when I send data back to the server I can tell it what text goes to what field. (So from a past example I can't set the next tab order in the tag).

So currently I'm creating a map, with my tab order (0,1,2,3 etc) as the key, and my edittext box as the value (for example 0,username and 1,password).

Here is my code:

B4X:
    Dim nextview As View
    Dim t As EditText
    t = Sender
    Dim mytag As String
    mytag = t.Tag
    Dim nextup As Int
    nextup = datamaptaborder2.Get(mytag)
    nextup = nextup + 1
    nextview = datamaptaborder.Get(nextup)
nextview.RequestFocus

I'm failing on the nextview.requestfocus line....

It's saying a string can't be cast as an android.view do I have any options here?

Thnx!
 

DonManfred

Expert
Licensed User
Longtime User
nextview = datamaptaborder.Get(nextup)
i guess the result is a string, not a View
What is datamaptaborder.Get(nextup)?

Upload a small project which shows the problem. Without knowing your code we can´t help.
 
Upvote 0

chrisinky

Member
Licensed User
Longtime User
Thanks - I just figured it out. I was creating the map when I was reading the data from the server, thus the map was being populated with for example 0,"Fieldname" (fieldname is a string at this point).

I had to create the map at the part in the sub where I create the edittext from the resulting data from the server, thus the edittext now exists and instead of passing the fieldname as a string I'm passing it as the edittext's name.
 
Upvote 0
Top