Disable autofocus of EditText at Activity startup

This question already has an answer here:

  • Stop EditText from gaining focus at Activity startup 46 answers

  • Answer :

    For Activity: place the below code into your onCreate() method

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    For Fragment: place the below code into your onCreateView() method

    getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

    链接地址: http://www.djcxy.com/p/24174.html

    上一篇: 如何防止关注活动开始

    下一篇: 在Activity启动时禁用EditText的自动对焦