gpt4 book ai didi

android点击editText后尝试打开键盘

转载 作者:行者123 更新时间:2023-11-29 21:11:09 28 4
gpt4 key购买 nike

我正在尝试打开键盘,但我进入了 logcat

682-682/com.android.inputmethod.latin V/InputMethodService﹕ onEvaluateInputViewShown: config.hardKeyboardHidden = 1

我的代码:

   InputMethodManager imm = (InputMethodManager) this.getSystemService(Service.INPUT_METHOD_SERVICE);

editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {

@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
} else {

}
}
});

谢谢!

最佳答案

试试这个,

在你的 Activity 顶部声明它

InputMethodManager imm = (InputMethodManager)this.getSystemService(Service.INPUT_METHOD_SERVICE);

在 edittext 里面就用这个,

imm.showSoftInput(editText, 0);

否则你也可以试试这个,

InputMethodManager m = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if(m != null){
m.toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT);
}

关于android点击editText后尝试打开键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22785280/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com