支持国产操作系统国产应用!

捉蛋网

当前位置: 捉蛋网>教程>Android开发>

自定义Dialog中得EditText弹出键盘

时间:2013-06-05 16:34来源: 作者: 点击:
  自定义了Dialog然后弹出软键盘,但是键盘不属于当前活动窗口

代码如下
private View textEntryView;
        AlertDialog myDialog = null;
        private EditText post;

        private void showMyDialog() {
                LayoutInflater factory = LayoutInflater.from(this);
                textEntryView = factory.inflate(R.layout.managerview, null);
                textEntryView.findFocus();
                myDialog = new AlertDialog.Builder(this).create();
                myDialog.show();
               
           myDialog.getWindow().setContentView(textEntryView);
           getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
                InputMethodManager imm = (InputMethodManager)
                                getSystemService(INPUT_METHOD_SERVICE);
                                 imm.showSoftInput(textEntryView, 0); //显示软键盘
                                 imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); //显示软键盘


        }


效果图:

 

(责任编辑:捉蛋网-刷机)
............................................................................................... ...............................................................................................

 

顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------