gpt4 book ai didi

android - 无法打开自动完成文本的软键盘

转载 作者:行者123 更新时间:2023-11-30 03:41:52 24 4
gpt4 key购买 nike

在 Eclipse 中测试自动完成文本控件时,我无法让软键盘显示在我的三星手机上。我点击以物理触摸自动完成文本控件以调出键盘。不允许显示软键盘的 AutoCompleteText 控件有什么不同之处。下面是我在 Activity 的 onCreate 方法中的代码。我将不胜感激任何帮助。

    autoComplete = (AutoCompleteTextView) findViewById(R.id.suggest);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(autoComplete, InputMethodManager.SHOW_FORCED);
if (imm != null){
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
}
// imm.toggleSoftInput(0, 0);

autoComplete.addTextChangedListener(new TextWatcher(){

public void afterTextChanged(Editable editable) {
// TODO Auto-generated method stub

}

public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub

}

public void onTextChanged(CharSequence s, int start, int before, int count) {
String newText = s.toString();
int len = newText.length();
// Toast.makeText(getApplicationContext(), "Text changed count = " + String.valueOf(len), Toast.LENGTH_LONG).show();
if(len > 1)
new getData().execute(newText);
}

});

最佳答案

试试这个

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

这将强制键盘显示

关于android - 无法打开自动完成文本的软键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15589439/

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