关闭DialogFragment后面的点击活动?

时间:2019-04-29 07:48:59

标签: android 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();
}

}

2 个答案:

答案 0 :(得分:0)

您可以在onCreateDialog方法中设置canable can false

喜欢

this.setCancelable(false)

答案 1 :(得分:0)

如果定义rootLayout,则可以禁用布局中的所有视图。还可以在打开对话框片段之前应用活动。

private val client = WebClient.builder()
        .baseUrl(config.baseUrl)
        .uriBuilderFactory(DefaultUriBuilderFactory(config.baseUrl).apply {
            encodingMode = DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY
        })
        /*.clientConnector(ReactorClientHttpConnector(HttpClient.create().tcpConfiguration { tcpClient ->
            tcpClient.bootstrap { b ->
                BootstrapHandlers.updateLogSupport(
                    b,
                    LOGGING_HANDLER
                )
            }
        }))*/
        .defaultHeaders { headers ->
            headers.setBasicAuth(config.username, config.password)
        }
        .build()