当前位置: 代码迷 >> Android >> AlertDialog等待用户操作解决方法
  详细解决方案

AlertDialog等待用户操作解决方法

热度:22   发布时间:2016-05-01 21:28:47.0
AlertDialog等待用户操作
怎么才能让用户点击了AlertDialog弹出框的某个按钮才继续运行
而不是在弹出框存在的情况下运行后面的函数

------解决方案--------------------
后面的函数放在按钮事件监听里。
------解决方案--------------------
将后面的函数放到Onclick的事件处理中
------解决方案--------------------
AlertDialog.Builder alertDialog = new AlertDialog.Builder(ShoppingShow.this);
alertDialog.setTitle("").setMessage("AlertDialog").setPositiveButton("是", new android.content.DialogInterface.OnClickListener(){

public void onClick(DialogInterface dialog, int which) {

// TODO Auto-generated method stub
//点击“是”后想干的事情加进来

}}).setNegativeButton("否", new android.content.DialogInterface.OnClickListener(){



public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
//点击“是”后想干的事情加进来
}}).create().show();

------解决方案--------------------
setNegativeButton("按钮文字",点击事件(){
//你想这里干啥都行!!!!!!!!
})
  相关解决方案