focus of EditText in android

This question already has an answer here:

  • Stop EditText from gaining focus at Activity startup 46 answers

  • First test in your xml file that you may have this line in your edit text <requestFocus /> remove it, and here is some example which can help you Example link

    <EditText
       android:id="@+id/name"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       >
    
       <-- remove this line /// <requestFocus /> 
    </EditText>
    

    also add this in your activity

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

    在你的layout.xml中,删除这行(在EditText的底部):

     <requestFocus />
    

    最好的解决方案是:(在Manifest文件中)

        <activity android:name=".MainActivity" 
    
            android:windowSoftInputMode="stateHidden" />
    
    链接地址: http://www.djcxy.com/p/24172.html

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

    下一篇: 在android中的EditText的焦点