Reputation: 3666
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>
Upvotes: 0
Views: 4656
Reputation: 1305
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);
Upvotes: 4