项目中遇到这样的需求:点击一个按钮,弹出对话框,同时弹出软件盘,经过一番查找,终于解决了这个问题 当调用Dialog的show()方法的时候,只需要用handle来发送消息,打开软件盘,代码如下
PRivate Handler handler = new Handler(){ public void handleMessage(Message msg) { //在需要弹出软键盘的地方发送msg if (msg.what==1000){ //使用以下代码来弹出软键盘 InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(getapplicationContext().INPUT_METHOD_SERVICE); inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); } } };新闻热点
疑难解答