Question

I know their are 100 posts about this one, and somehow it isn't working for me. I got an EditText, and when I "touch" that box, the keyboard must appear.

This is everything I tried already:

public void onClick(View v) {
             EditText Edit_perceel_nr2 = (EditText)findViewById(R.id.Perceel_nr2);;
             InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
             imm.hideSoftInputFromWindow(Edit_perceel_nr2.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

and

public void onClick(View v) {
             EditText Edit_perceel_nr2 = (EditText)findViewById(R.id.Perceel_nr2);;
             InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
             imm.hideSoftInputFromWindow(Edit_perceel_nr2.getWindowToken(), 0);

and

 public void onClick(View v) {

             EditText Edit_perceel_nr2 = (EditText)findViewById(R.id.Perceel_nr2);;
             ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(Edit_perceel_nr2, 0);

and

public void onClick(View v) {

             EditText Edit_perceel_nr2 = (EditText)findViewById(R.id.Perceel_nr2);;
             ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(Edit_perceel_nr2, InputMethodManager.SHOW_IMPLICIT);

I even tried to add this in the manifest:

android:windowSoftInputMode="stateAlwaysVisible"

But I can't get it to work. Probably I forgot something, but I am out of ideas now. Someone got more ideas or the solution?

This is my edittext:

<EditText
    android:id="@+id/Perceel_nr2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="number"
    android:text="text"> 
</EditText>
Was it helpful?

Solution

Try with this..

EditText yourEditText= (EditText) findViewById(R.id.yourEditText);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT);

To Close u can use

  InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
 imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top