Android Question Focus on start up

stu14t

Active Member
Licensed User
Longtime User
I have a tabhost with numerous Edittext, how or what controls which edittext has the initial focus on startup?

I have a series of edittext that accept input sequentially from the user. For some reason the last edittext in the order has focus on start-up. I could force the focus away to the correct edittext; however, I have code that warns the user that input it necessary and this is triggered if I forcibly move the focus.

It would be easier to ensure the first edittext has focus from the start.

Edit: Ok, found out it's something to do with the tree order in the designer that decides what has focus first. Can this be changed grammatically?
 
Last edited:

stu14t

Active Member
Licensed User
Longtime User
Yes, I use the Tab order class in my app. The class just sets the tab order but does not set the initial focus

If I change the focus after the layout has loaded this triggers the changed focus event, which in turn triggers my code that warns the user that the edittext that had the focus initially is empty and must be filled. This is expected behavior, but the order of input is from top to bottom. If the app starts you at the wrong point, being warned there is nothing in the edittext that is not at the start is an annoyance to the user. (if that makes sense)

I have subsequently discovered it may have something to do with the tree order within the designer My question is, what dictates the first edittext to receive focus and if that can be changed programmatically at or before the layout loads.
 
Upvote 0
Top