How come the Android soft keyboard is not responding to EditText?

可紊 提交于 2019-12-01 04:45:13
hasanghaforian

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

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 that it is not guaranteed.Really I did not any way to appear soft keyboard programmatically.Some times it appears and some times not.In emulator with android 4.0.3,you can see a symbol in notification bar instead of appearing soft keyboard:

Look at:
Event for Handling the Focus of the EditText
Forcing the Soft Keyboard open

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!