700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > android软键盘自动弹出 android安卓editText自动弹出软键盘(输入键盘)

android软键盘自动弹出 android安卓editText自动弹出软键盘(输入键盘)

时间:2019-09-10 03:41:22

相关推荐

android软键盘自动弹出 android安卓editText自动弹出软键盘(输入键盘)

editext获取焦点并自动弹出输入键盘,代码如下:

EditTexteditText.setFocusable(true);

editText.setFocusableInTouchMode(true);

editText.requestFocus();

InputMethodManagerinputManager=(InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

inputManager.showSoftInput(editText,0);

如果是已经入某个界面就要立刻弹出输入键盘,可能会由于界面未加载完成而无法弹出,需要适当延迟,比如延迟500毫秒:

Timertimer=newTimer();

timer.schedule(newTimerTask()

{

publicvoidrun()

{

InputMethodManagerinputManager=(InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

inputManager.showSoftInput(editText,0);

}

},500);

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。