在AlertDialog对话框中弹出软键盘
来源:互联网 发布:qq堂mac版官方下载 编辑:程序博客网 时间:2024/05/20 07:19
这是第一种方法
public void addcomment() { // 1.创建弹出式对话框 final AlertDialog.Builder alertDialog = new android.app.AlertDialog.Builder(mActivity); // 系统默认Dialog没有输入框 // 获取自定义的布局 View alertDialogView = View.inflate(mActivity, R.layout.dialog_punchcard_addcomment, null); final AlertDialog tempDialog = alertDialog.create(); tempDialog.setView(alertDialogView, 0, 0, 0, 0); //文本输入框 final EditText et_addcomment = (EditText) alertDialogView.findViewById(R.id.et_addcomment); //取消按钮 Button btn_addcomment_ok = (Button) alertDialogView.findViewById(R.id.btn_addcomment_ok); btn_addcomment_ok.setOnClickListener(new OnClickListener() {@Override public void onClick(View arg0) { tempDialog.dismiss(); } }); //确然按钮 Button btn_addcomment_cancel = (Button) alertDialogView.findViewById(R.id.btn_addcomment_cancel); btn_addcomment_cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) {} }); /** 3.自动弹出软键盘 **/ /*getSystemService()如果在activity里面就可以直接调用,如果在其他的地方要先调用getActivity()*/ tempDialog.setOnShowListener(new OnShowListener() { public void onShow(DialogInterface dialog) { InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(et_addcomment, InputMethodManager.SHOW_IMPLICIT); } }); tempDialog.show();}}
第二种方法 就是将AlertDialog改成Dialog;
0 0
- 在AlertDialog对话框中弹出软键盘
- 在service中弹出全局对话框AlertDialog
- Service中弹出AlertDialog对话框
- 在Service中弹出AlertDialog
- 在驱动中弹出对话框
- 在servlet中弹出对话框
- 在servlet中弹出对话框
- 在servlet中弹出对话框
- 在Service中弹出对话框
- 在broadcastReceiver 中弹出对话框
- 在服务中弹出alertDialog和activity
- 使用AlertDialog实现使用在android中弹出对话框,询问用户是否继续执行
- 在ASP.net中弹出"另存为"对话框
- 在网页中弹出一个自定义对话框
- 在服务程序中弹出对话框
- 在服务程序中弹出对话框
- 在服务程序中弹出对话框
- 在服务程序中弹出对话框
- 关于广播的一种写法
- 重温二项分布
- 理解Handler,Looper,MessageQueue,ThreadLocal关系
- virtualbox ubuntu 设置共享文件夹
- hbase的shell小技巧
- 在AlertDialog对话框中弹出软键盘
- Android支付接入:Google In-app-Billing
- iOS多线程编程技术之NSThread、NSOperation、GCD
- 各种时间日期工具类
- Python数据类型:列表、阵列
- HDU 1062 Text Reverse 水题 字符串处理
- jdk,jre,jvm 三者间的差别与联系
- [easyUI] textbox的disabled属性和disable方法
- pp看书笔记---C#高级编程第九版 第六章 【数组】