0

I'm trying to make a simple calculator and to do so, I want to, and exit view that the user can move the courser within but can only input based off of the buttons I've included.

When I press on the Edittext view, however, the keyboard pops up and I can't figure out how to suppress it - I've tried both android:windowSoftInputMode="stateAlwaysHidden" and android:configChanges="keyboardHidden" in the manifest and also

InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
//Hide keyboard
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

In Java but none of them work

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Jeremy
  • 1,337
  • 3
  • 12
  • 26
  • Sounds like this question. http://stackoverflow.com/questions/4880144/android-how-to-permanently-completely-not-show-default-soft-keyboard-for-an-e?rq=1 – OneCricketeer Oct 05 '16 at 21:09

2 Answers2

1

thanks for the help but I've just found a solution

XML:

   <EditText
        android:id="@+id/InputLine"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_above="@id/Sixth_Up"
        android:onClick="hideKeyboard">

    </EditText>

Java:

public void hideKeyboard(View v) {
    InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mgr.hideSoftInputFromWindow(editInput.getWindowToken(),0);
}
Jeremy
  • 1,337
  • 3
  • 12
  • 26
0

You can check that view is in focus and then hide the keyboard.

View view = this.getCurrentFocus();
if (view != null) {  
    InputMethodManager manager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    manager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
The SE I loved is dead
  • 1,517
  • 4
  • 23
  • 27
Taras Smakula
  • 331
  • 2
  • 7