关闭DialogFragment后面的click activity?
Turn off click activity behind DialogFragment?
打开对话框片段时无法取消后台按钮的点击事件。我正在尝试通过另一个片段中的按钮调用对话框片段。
public class DialogPaymentSuccessFragment extends DialogFragment {
private View root_view;
class rootViewClick implements OnClickListener {
rootViewClick () {
}
public void onClick(View view) {
DialogPaymentSuccessFragment.this.dismiss();
}
}
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
this.root_view = layoutInflater.inflate(R.layout.dialog_payment_success, viewGroup, false);
((FloatingActionButton) this.root_view.findViewById(R.id.fab)).setOnClickListener(new rootViewClick());
return this.root_view;
}
@NonNull
public Dialog onCreateDialog(Bundle bundle) {
bundle = super.onCreateDialog(bundle);
bundle.requestWindowFeature(1);
return bundle;
}
public void onDestroyView() {
super.onDestroyView();
}
}
您可以在 onCreateDialog
方法中设置 cancel able false
像这样
this.setCancelable(false)
如果你定义了rootLayout,你可以禁用layout.You中的所有视图,也可以在打开dialogfragment之前应用activity。
public static void enableDisableView(View view, boolean enabled) {
view.setEnabled(enabled);
if ( view instanceof ViewGroup) {
ViewGroup group = (ViewGroup)view;
for ( int idx = 0 ; idx < group.getChildCount() ; idx++ ) {
enableDisableView(group.getChildAt(idx), enabled);
}
}
}
打开对话框片段时无法取消后台按钮的点击事件。我正在尝试通过另一个片段中的按钮调用对话框片段。
public class DialogPaymentSuccessFragment extends DialogFragment {
private View root_view;
class rootViewClick implements OnClickListener {
rootViewClick () {
}
public void onClick(View view) {
DialogPaymentSuccessFragment.this.dismiss();
}
}
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
this.root_view = layoutInflater.inflate(R.layout.dialog_payment_success, viewGroup, false);
((FloatingActionButton) this.root_view.findViewById(R.id.fab)).setOnClickListener(new rootViewClick());
return this.root_view;
}
@NonNull
public Dialog onCreateDialog(Bundle bundle) {
bundle = super.onCreateDialog(bundle);
bundle.requestWindowFeature(1);
return bundle;
}
public void onDestroyView() {
super.onDestroyView();
}
}
您可以在 onCreateDialog
方法中设置 cancel able false
像这样
this.setCancelable(false)
如果你定义了rootLayout,你可以禁用layout.You中的所有视图,也可以在打开dialogfragment之前应用activity。
public static void enableDisableView(View view, boolean enabled) {
view.setEnabled(enabled);
if ( view instanceof ViewGroup) {
ViewGroup group = (ViewGroup)view;
for ( int idx = 0 ; idx < group.getChildCount() ; idx++ ) {
enableDisableView(group.getChildAt(idx), enabled);
}
}
}