RecyclerView(三):点击RecyclerView的某一个Item,弹出PopupWindow,然后再点击PopupWindow的item,弹出对话框

View view = getLayoutInflater().inflate(R.layout.fragment_linear_recycler_view,null);
View view1 = getLayoutInflater().inflate(R.layout.layout_popupwindow,null);
TextView textViewEdit = view1.findViewById(R.id.text_view_edit);
TextView textViewDelete = view1.findViewById(R.id.text_view_delete);

popupWindow = new PopupWindow(view1, WindowManager.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.WRAP_CONTENT);
popupWindow.setOutsideTouchable(true);
// popupWindow.setFocusable(true);
popupWindow.showAtLocation(view, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);

textViewEdit.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        lighton();
        popupWindow.dismiss();
        AlertDialog.Builder builder1 = new AlertDialog.Builder(ManagementActivtiy.this);
        View view = LayoutInflater.from(ManagementActivtiy.this).inflate(R.layout.fragment_alert_dialog_two,null);
        EditText editTextName = view.findViewById(R.id.edit_text_name);
        EditText editTextNumber = view.findViewById(R.id.edit_text_number);
        builder1.setMessage("请修改")
                .setView(view)
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(ManagementActivtiy.this,"已经修改",Toast.LENGTH_SHORT).show();
                        dialog.dismiss();
                    }
                })
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(ManagementActivtiy.this,"取消修改",Toast.LENGTH_SHORT).show();
                        dialog.dismiss();
                    }
                })
                .show();
    }
});

textViewDelete.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        lighton();
        popupWindow.dismiss();
        AlertDialog.Builder builder = new AlertDialog.Builder(ManagementActivtiy.this);
        builder.setMessage("你确定要删除吗?")
                .setPositiveButton("是", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(ManagementActivtiy.this,"已经删除",Toast.LENGTH_SHORT).show();
                    }
                })
                .setNegativeButton("否", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(ManagementActivtiy.this,"取消删除",Toast.LENGTH_SHORT).show();
                    }
                })
                .show();
    }
});
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值