【发布时间】:2019-04-29 07:48:58
【问题描述】:
当我打开一个对话框片段时,我无法取消后台按钮的点击事件。我正在尝试通过另一个片段中的按钮调用对话框片段。
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();
}
}
【问题讨论】:
-
这看起来像反编译代码..
-
当您的活动包含 CollapsingToolbarLayout 时您是否面临此问题
-
在xml中设置
dialog可点击的根项为false。在dialog_payment_success.xml根项中添加android:clickable="false" -
发布对话框片段的 xml 代码