I'm testing my app on android 4.0.4 Samsung galaxy duos, the problem is if I set:
android:textIsSelectable="true"
the keyboard doesn't appear, though it appears on the emulator. Any suggestions?
Here is how my EditBox
looks like
<EditText
android:focusable="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textVisiblePassword|textCapWords|textMultiLine"
android:textIsSelectable="true"
android:gravity="top|left"
android:minLines="6"
android:maxLines="10"
android:minHeight="140dp"
android:hint="@string/message"
/>
<requestFocus />
To enable your latest Android keyboard, scroll to the bottom and hit the System entry. Then, click Languages & input. Pick Virtual keyboard on the following page. You will find a list of all the existing keyboards on your smartphone here.
How do I enable the keyboard for simulator? Click the simulator menu Hardware —> Keyboard, check the Connect Hardware Keyboard sub-menu, and then uncheck it at once. Now the keyboard will be prompted automatically when you click the text field or text view UI component in the iOS simulator.
The Android system shows an on-screen keyboard—known as a soft input method—when a text field in your UI receives focus.
Add a requestfocus. In xml:
<EditText>
<requestFocus />
</EditText>
Programmatically
edittext.requestFocus();
To "force" the SoftKeyboard to appear, you can do it dynamically:
InputMethodManager mImm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
mImm.showSoftInput(SearchEdit, InputMethodManager.SHOW_IMPLICIT);
Set onFocusChangeListener to appear your keyboard:
edittext.setFocusable(true);
edittext.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus)
mImm.showSoftInput(SearchEdit, InputMethodManager.SHOW_IMPLICIT);
else
mImm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
}
});
See InputMethodManager Documentation for more information.
See also these answers to forcing the Keyboard to appear: Forcing the Soft Keyboard open
You need to put requestFocus
inside EditText
element:
<EditText
android:focusable="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textVisiblePassword|textCapWords|textMultiLine"
android:textIsSelectable="true"
android:gravity="top|left"
android:minLines="6"
android:maxLines="10"
android:minHeight="140dp"
android:hint="@string/message">
<requestFocus />
<EditText/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With