android prevent EditText from requesting focus automatically

前端 未结 4 1283
情话喂你
情话喂你 2021-01-12 14:02

I have a quite simple Layout with an EditText and a button. The problem is the keyboard appears immediately after the activity is started and the EditText gets the focus. I

4条回答
  •  没有蜡笔的小新
    2021-01-12 14:41

    From my POV a more elegant solution is:

    1. In XML add these lines to the main layout:

      
      
    2. And In Java in onCreate():

        LinearLayout mainLayout = (LinearLayout) findViewById(R.id.mainLayout);
        mainLayout.requestFocus();
      

提交回复
热议问题