1

In my app, I have an EditText. How do I make it doesn't start automatically? Like: once they open the activity it automatically sets the mouse to the EditText and the keyboard gets opened so they type…

Is there anyway I can make it open (the keyboard shows and the user can type) when they clicks on it?

John Jared
  • 790
  • 3
  • 16
  • 40

2 Answers2

1

Ok, so from your question i figure out that your EditText is getting focus while starting the activity. You can disable the focus using following command to suppress the keyboard.

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

Visit this Close/hide the Android Soft Keyboard

Community
  • 1
  • 1
Lucifer
  • 29,392
  • 25
  • 90
  • 143
0

the answer by Lucifer must work. But when i got the same problem, that solution did't work, and someone suggested me this.

add a fake layout as the first element in you parent layout and make it focusable.

Like this:

<ParentLayout
     .....
     ......>
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@android:color/transparent"
        android:focusable="true"
        android:focusableInTouchMode="true" >
    </LinearLayout>

     ......
     ......
     ......

</ParentLayout>

This definitely works, but the best solution is:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226