在Eclipse中测试自动完成文本控件时,我无法在三星手机上显示软键盘。我点击了物理触摸autocompletetext控件来调出键盘。 AutoCompleteText控件是否有不同之处,不允许显示软键盘。下面是我的活动的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);
}
});
答案 0 :(得分:1)
试试这个
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
这将强制键盘显示