mButton = findViewById(R.id.searchbutton);//获取布局按钮 mButton.setOnClickListener(new View.OnClickListener() {//设置监听事件 @Override public void onClick(View view) { switch (view.getId()){ case R.id.searchbutton: AlertDialog.Builder dialog = new AlertDialog.Builder(searchMainActivity.this); dialog.setTitle("确认保存"); dialog.setMessage("确认数据无误?"); dialog.setCancelable(false); dialog.setPositiveButton("确认", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); dialog.show(); break; default: break; } } });
AlertDialog 安卓弹窗设置
最新推荐文章于 2024-06-28 17:18:36 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)