利用dialog.getButton().setEnabled()实现按钮使能
来源:互联网 发布:java聊斋聂小倩 编辑:程序博客网 时间:2024/06/06 05:45
<span style="font-family: Arial, Helvetica, sans-serif;"> AlertDialog.Builder builder = new AlertDialog.Builder(CheckTableActivity.this);</span> LayoutInflater inflater = getLayoutInflater(); View view = inflater.inflate(R.layout.input_dialog, null); dg_danger = (EditText) view.findViewById(R.id.editText1); dg_score = (EditText) view.findViewById(R.id.editText2); dg_spinner = (Spinner) view.findViewById(R.id.spinner1); final int num = vp_curr>0?(vp_curr-1):0; danger_flag = 0; score_flag = 0; // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout builder.setView(view) // Add action buttons .setPositiveButton("确认", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { addListItem(num, dg_danger.getText().toString(), dg_score.getText().toString()); System.out.println(dg_danger.getText().toString() + ";" + dg_score.getText().toString()); } }).setNegativeButton("取消", null).setTitle("添加隐患条目"); AlertDialog ad = builder.create(); ad.setView(view); ad.show();//show之后再获取按钮 final Button positiveButton = ad.getButton(AlertDialog.BUTTON_POSITIVE); positiveButton.setEnabled(false); System.out.println("setEnabled false"); //edittext文本改变监听,下同 dg_danger.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { System.out.println("danger changed"); if(arg0.toString().trim().equals("")){ danger_flag = 0; positiveButton.setEnabled(false); System.out.println("set enabled false"); } else { danger_flag = 1; if(score_flag == 1) { positiveButton.setEnabled(true); System.out.println("set enabled true"); } } } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {}}); dg_score.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { System.out.println("score changed"); if(arg0.toString().equals("")){ score_flag = 0; positiveButton.setEnabled(false); System.out.println("set enabled false"); } else { score_flag = 1; if(danger_flag == 1) { positiveButton.setEnabled(true); System.out.println("set enabled true"); } } } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {} });
0 0
- 利用dialog.getButton().setEnabled()实现按钮使能
- setEnabled
- 按钮控件使能
- 实现dialog点击按钮后不消失
- 利用MFC按钮使能(或禁用)属性使按钮变正常色(或灰色)
- cocos2d-x ui::Button 的setEnabled 和 setVisible 的区别,setEnabled后按钮却不见了
- 利用重写Dialog实现自定义对话框
- 使Dialog的关闭按钮失效
- 使Dialog的关闭按钮失效
- QT 项目修改——dialog也能拥有最大化最小化按钮
- Android 自定义dialog,实现右上角显示一个控件按钮
- 自定义dialog,实现右上角显示一个控件按钮
- dialog里面实现自定义样式单选按钮功
- dialog的使用,按钮的两种实现方式
- 利用vbs类实现css按钮
- 利用CSS实现按钮效果(无图片)
- 利用pngimage实现PNG图形化按钮
- 利用css3实现漂亮下载按钮
- uva 10020 Minimal coverage
- 【Eclipse】【FAQ】Eclipse工程原来使用好好的,突然内存溢出异常关闭了,基本的jdk类就识别不了——删除jre重新加到编译路径中解决
- 即将毕业.
- JavaScript快速入门(六)——DOM
- java线程池_ExecutorService
- 利用dialog.getButton().setEnabled()实现按钮使能
- WCF分布式框架
- Unity3d中脚本无法编译问题(Monodevelop)
- uva11584 划分成回文串
- python开发环境搭建(python3.3.2+wing IDE4.1)
- UVa 1099 分巧克力 ACM解题报告(状压dp)
- 直播:全能项目经理 - 设计篇(2015-2-16)
- UVa 11925 - Generating Permutations(构造法)
- android项目导入出现红色叹号