Keyboard Not Shown When I Click on Edittextview in Android

EditText not showing a keyboard

Just remove

android:descendantFocusability="blocksDescendants" 

in main RelativeLayout. You will get the focus in the Edittext.BlockDescendants will prevent the child layouts from getting focus. Check http://developer.android.com/reference/android/view/ViewGroup.html#attr_android:descendantFocusability

How to show soft-keyboard when edittext is focused

To force the soft keyboard to appear, you can use

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

And for removing the focus on EditText, sadly you need to have a dummy View to grab focus.


To close it you can use

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0);

This works for using it in a dialog

public void showKeyboard(){
InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}

public void closeKeyboard(){
InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
}

android - edittext keyboard not showing

I was having the same problem and nothing worked until I found an answer way down in one of the posts from years ago that worked. I'll repost the weird hack for anyone who might have this problem in the future.

In your xml file, add a dummy edittext to your topmost layout layer that looks like this:

<EditText
android:id="@+id/editTextFix"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
tools:targetApi="o"
android:inputType="text"
android:visibility="gone"/>

the dummy edittext will open the keyboard, but your programatically created edittext will still have focus.

EditText not focusing, and not showing keyboard after keyboard is hidden after one input

Put this line when you want to give it focus:

otpField.requestFocus();

Also, to show the soft keyboard explicitly, you can do like below:

otpField.postDelayed(new Runnable() {
@Override
public void run() {
InputMethodManager im = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
im.showSoftInput(otpField, InputMethodManager.SHOW_IMPLICIT);
}
},200);

Android EditText doesn't show the Keyboard

Please add attribute android:windowSoftInputMode="adjustResize" in AndroidManifest.xml

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

...
</activity>

EditText onClick not shows Virtual Keyboard

Try with this, it worked for me.

EditText etHorseName = (EditText) getView().findViewById(R.id.horseName);
etHorseName.clearFocus();

in onCreate() or where you want.

Android click on EditText won't show softkeyboard

I found the solution, I just had to remove the following attribute from my EditText:

android:textIsSelectable="true"


Related Topics



Leave a reply



Submit