1

在此处输入图像描述在我的代码中,我在弹出视图中显示警报。但是当我触摸任何背景按钮时,它们就会启用。我想禁用背景触摸。以下是我的代码。请检查一下。

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View popuplayoutReject = inflater.inflate(R.layout.popup_reject_request, (ViewGroup) findViewById(R.id.popup_element));
final PopupWindow popUpReject = new PopupWindow(popuplayoutReject, WindowManager.LayoutParams.WRAP_CONTENT,
        WindowManager.LayoutParams.WRAP_CONTENT, false);
ImageButton btnPopupReject_Ok, btnPopUpReject_Cancel;
TextView txtRequestRejectMessage = (TextView) popuplayoutReject.findViewById(R.id.errorMessage);
txtRequestRejectMessage.setText(getResources().getString(R.string.AddEntryNotSaved));
btnPopupReject_Ok = (ImageButton) popuplayoutReject.findViewById(R.id.btnPopup_Yes);
btnPopupReject_Ok.setImageResource(R.drawable.yes_button);

btnPopupReject_Ok.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
       finish();
    }
});

btnPopUpReject_Cancel = (ImageButton) popuplayoutReject.findViewById(R.id.btnPopUp_No);
btnPopUpReject_Cancel.setImageResource(R.drawable.no_button);
btnPopUpReject_Cancel.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        popUpReject.dismiss();
    }
});
popUpReject.showAtLocation(popuplayoutReject, Gravity.CENTER, 0, 0);            
4

2 回答 2

2

刚刚完成实施

final PopupWindow popUpReject = new PopupWindow(popuplayoutReject, WindowManager.LayoutParams.FILL_PARENT,
                            WindowManager.LayoutParams.FILL_PARENT, false);
                    popUpReject.setOutsideTouchable(false);
于 2013-01-23T05:57:23.173 回答
-1

你的代码

 final PopupWindow popUpReject = new PopupWindow(popuplayoutReject, WindowManager.LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.WRAP_CONTENT, false);

固定代码

 final PopupWindow popUpReject = new PopupWindow(popuplayoutReject, WindowManager.LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.WRAP_CONTENT, true);
于 2016-05-03T04:28:23.410 回答