【发布时间】:2011-12-26 00:55:58
【问题描述】:
我正在设计一个登录页面:
UserName: .....
Password: .....
LoginButton
当活动开始时,我希望焦点转到“用户名”文本框并出现键盘。
我正在使用以下代码:
boolean checkFocus=user.requestFocus();
Log.i("CheckFocus", ""+checkFocus);
if(checkFocus==true)
{
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(user, InputMethodManager.SHOW_IMPLICIT);
}
我不明白在哪里编写此代码以使键盘在活动开始时出现并且焦点位于“用户名”编辑文本框上。谁能指导一下?
【问题讨论】:
标签: android android-layout android-edittext