我有旧的片段代码,我需要从编写为可组合的片段对话框中打开:
我有这样的课:
class FullScreenDialogActivity
@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
AbstractComposeView(context, attrs) {
@Composable
override fun Content() {
Dialog(
title = "d",
desc = "",
onDismiss = {
dialog.value = false
}
)
}
但是我怎样才能从java片段类打开这样的对话框呢?
public class MyFragment extends Fragment {
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
//FullScreenDialogActivity()
}
}
这个对话框应该位于片段的顶部
您可以从任何片段方法调用它,如下所示:
private void yourMethodOrOnClickMethodFromXml() {
FullScreenDialogActivity dialog = new FullScreenDialogActivity(getContext());
getActivity().setContentView(dialog);
}