How to set focus on a view when a layout is created and displayed?

user256239 picture user256239 · Jan 27, 2010 · Viewed 160.5k times · Source

Currently, I have a layout which contains a Button, a TextView and an EditText. When the layout is displayed, the focus will be automatically put on the EditText, which will trigger the keyboard to show up on Android phone. It is not what I want. Is there any way that I can set the focus on TextView or on nothing when a layout is displayed?

Answer

Mark B picture Mark B · Jan 27, 2010

Set focus: The framework will handled moving focus in response to user input. To force focus to a specific view, call requestFocus()