How to set focus on a TextView when an Activity starts?

前端 未结 7 1571
我在风中等你
我在风中等你 2020-12-28 15:49

There are an EditText and a TextView in my Activity. I want to set focus on the TextView when the Activity starts. I used the following code:

    TextView my         


        
7条回答
  •  没有蜡笔的小新
    2020-12-28 16:18

    I came across with your question now. Maybe after 2 years you have found a solution. But I write it here for the others that will come across with this in the future. The only thing you have to do is to go to the AndroidManifest.xml, find the Activity in which you want this behaviour and add this android:windowSoftInputMode="stateHidden". So, at the start of your Activity no keyboard will be shown, until you touch the EditText object.

提交回复
热议问题