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

后端 未结 15 1232
Happy的楠姐
Happy的楠姐 2020-12-02 15:07

Currently, I have a layout which contains a Button, a TextView and an EditText. When the layout is displayed, the focus will be automa

15条回答
  •  没有蜡笔的小新
    2020-12-02 15:54

    The last suggestion is the correct solution. Just to repeat, first set android:focusable="true" in the layout xml file, then requestFocus() on the view in your code.

提交回复
热议问题