1

when i touch textedit, the keyboard android opens.

I want to stop that.

My code:

activity_main.xml

<EditText
        android:id="@+id/edit_box"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:focusable="true"
        android:background="#ffffff">

</EditText>

Main.java

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        caixa = (EditText)findViewById(R.id.edit_box);
        InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
           imm.hideSoftInputFromWindow(caixa.getWindowToken(),InputMethodManager.RESULT_UNCHANGED_SHOWN);
Luis Abreu
  • 11
  • 3

2 Answers2

0

You can hide the keyboard in the manifest:

<activity
...
android:windowSoftInputMode="stateHidden" >

</activity>
Bene
  • 724
  • 8
  • 20
0

Try this:

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

 imm.hideSoftInputFromWindow(caixa.getWindowToken(), 0);
Ashish Sahu
  • 1,538
  • 17
  • 22