(安卓) AlertDialog 弹出对话框效果

来源:互联网 发布:js 按钮显示 隐藏 div 编辑:程序博客网 时间:2024/05/18 02:21

上图:


import android.app.AlertDialog;


先设置一个单击事件触发对话框:

 //查找控件,设置点击事件                holder.butt.setOnClickListener(new View.OnClickListener() {                    @Override                    public void onClick(View view) {                        //对话框                        duihukuan(position);                    }                });


对话框:

 private void duihukuan(final int position) {        AlertDialog.Builder builder = new AlertDialog.Builder(context);        builder.setTitle("删除此条数据.....")                .setPositiveButton("确认", new DialogInterface.OnClickListener() {                    @Override                    public void onClick(DialogInterface dialog, int which) {                        //集合里的删除点击的条目                        list.remove(position);                        //刷新适配器                        notifyDataSetChanged();                    }                })                .setNegativeButton("取消", new DialogInterface.OnClickListener() {                    @Override                    public void onClick(DialogInterface dialog, int which) {                    }                }).show();    }



原创粉丝点击