tags:

views:

881

answers:

1

In my android application it automatically focuses the first Button I have in my layout, giving it an orange outline. How can I set the initial focus preferably in XML, and can this be set to nothing?

+4  A: 

You could use the requestFocus tag:

<Button ...>
  <requestFocus />
</Button>

I find it odd though that it auto-focuses one of your buttons, I haven't observed that behavior in any of my views.

Matthias
Yeah, it has happened with two of my applications now. I guess I could requestFocus onto a element that doesn't change like a TextView or would this not be allowed?
stealthcopter
I believe it will work on any view that is focusable.
Matthias