Why doesn't my Android computer keyboard respond to EditText?

I have SherlockFragmentActivity and SherlockFragment which is inside the TabManager. In this snippet, I have RadioButtons, CheckBoxes, Button, and EditText in LinearLayout. The keyboard sometimes does not respond when you click on EditText.

In 2.1 AVD, the keyboard reacts inconsistently, in 4.0 AVD the keyboard does not respond at all, and on the device the keyboard reacts inconsistently. Sometimes pressing other objects activates the ability to display the keyboard.

Here is the XML for EditText:

<EditText android:id="@+id/EditText1" android:layout_width="100dp" android:layout_height="wrap_content" android:inputType="number" android:text="20" > 

I am more confused by incompatible activities than the fact that it does not work with 4.0 AVD. Any suggestions on why this is happening, or a way to show the keyboard, would be great.

+6
source share
1 answer

You can register a focus listener for your edittext and open a soft keyboard when it focuses:

 edit_Text.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if(hasFocus){ ((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)) .showSoftInput(edit_Text, InputMethodManager.SHOW_FORCED); }else Toast.makeText(getApplicationContext(), "lost the focus", 2000).show(); } }); 

Edit:
For emulator , I think this is not guaranteed. True, I could not programmatically program the software keyboard. Sometimes it appears and several times not. In an emulator with Android 4.0.3, you can see the symbol in the notification panel instead of the appearance of a soft keyboard:
enter image description here

Take a look:
EditText focus event
Disable soft keyboard

+5
source

Source: https://habr.com/ru/post/918050/


All Articles