Android : clear focus on edittext when activity starts

前端 未结 8 907
伪装坚强ぢ
伪装坚强ぢ 2021-01-02 14:30

I\'ve some settings page in my app. Once the activity gets starts directly it focus to edittext and i used following code to clear foucs.



        
相关标签:
8条回答
  • 2021-01-02 14:59

    If on starting the Activity it focuses on EditText on the screen. use

    android:focusableInTouchMode="true"
    

    in the parent containing that EditText. Like if EditText is inside a RelativeLayout use this line in the RelativeLayout.

    0 讨论(0)
  • 2021-01-02 15:02
    If Come back from other activity edittext get focused. 
    

    put these line onStart() or on onReusme()

      RelativeLayout focuslayout = (RelativeLayout) findViewById(R.id.RequestFocusLayout);
     focuslayout.requestFocus();
    
    0 讨论(0)
提交回复
热议问题