AlertDialog弹框

版权声明:橘子丶 https://blog.csdn.net/qq_43573190/article/details/86534898
newsAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, final int position) {
                AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
                builder.setIcon(R.mipmap.ic_launcher);
                builder.setTitle("啦啦啦");
                builder.setMessage("确定删除吗???");
                builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        newsBeansData.remove(position);
                        Toast.makeText(mContext, "您删除了第"+position+"条数据", Toast.LENGTH_SHORT).show();
                    }
                });
                builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(mContext, "您取消啦", Toast.LENGTH_SHORT).show();
                    }
                });
                builder.show();
                newsAdapter.notifyDataSetChanged();
            }
        });

猜你喜欢

转载自blog.csdn.net/qq_43573190/article/details/86534898
今日推荐