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();
}
});
RecyclerView(三):点击RecyclerView的某一个Item,弹出PopupWindow,然后再点击PopupWindow的item,弹出对话框
最新推荐文章于 2023-06-14 16:58:01 发布