我想隐藏键盘:View view = this.getCurrentFocus();if (view != null) { InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } }});现在我的问题,是getCurrentFocus和getSystemService是红色,它说:Cannot resolve method getCurrentFocus() / getSystemService()我究竟做错了什么?谢谢你的帮助!
1 回答
米琪卡哇伊
TA贡献1998条经验 获得超6个赞
这getSystemService
应该有一个context
之前:
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); // or context
或getActivity()
或类似的代码来获取上下文。
添加回答
举报
0/150
提交
取消