I have autocomplete edit text i want that show soft input keyboard even on focus or not on autocomplete. I tried so manny things but non of them is working. Like in Manifest :
<activity android:name=".MainActivity"
android:windowSoftInputMode="stateAlwaysVisible"
></activity>
In Activity :
number = (AutoCompleteTextView) findViewById(R.id.ed_number);
number.requestFocus();
InputMethodManager imms = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imms.showSoftInput(number, InputMethodManager.SHOW_FORCED);
if (!number.hasFocus()) {
imm.showSoftInput(number, 0);
number.requestFocus();
}
// on layout click it flickering on click like show/hide
linear_layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
InputMethodManager immq = (InputMethodManager) view.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
immq.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.SHOW_FORCED);
}
});
Your effort are handsome but i don't know why it is not going to set focus on AutoCompleteTextView
. So please try one more solution might be it can help you.
number.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(final View view, boolean hasFocus)
{
view.post(new Runnable()
{
@Override
public void run()
{
if (!view.hasFocus()) {
view.requestFocus();
view.requestFocusFromTouch();
}
}
});
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.