gpt4 book ai didi

安卓运行时异常 : requestFeature() must be called before adding content

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:00:41 24 4
gpt4 key购买 nike

<分区>

我有对话 fragment 。我打算在 Activity 和对话中使用这个 fragment 。我覆盖了 onCreateDialog 和 onCreateView 方法。这是编码。

    @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.interval_time_popup, null);
setup(view, false);
return view;
}

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
View view = getActivity().getLayoutInflater().inflate(R.layout.interval_time_popup, null);

builder.setTitle("Interval Time");
builder.setView(view);
setup(view, true);
builder.setPositiveButton("Set", new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {
listener.setOnIntervalTime(hourNp.getValue(), minNp.getValue());
dismiss();
}
});
builder.setNegativeButton("Cancel", new OnClickListener() {

public void onClick(DialogInterface dialog, int which) {
dismiss();
}
});
return builder.create();
}

我在 Activity 类中使用了这个 fragment 。

           SelectTimeIntervalDialogFragment fragment = new SelectTimeIntervalDialogFragment();
fragment.setHrMin(hr, min);
Bundle args = new Bundle();

FragmentTransaction t = getSupportFragmentManager().beginTransaction();
t.replace(R.id.shift_period_interval_layout, fragment);
t.commit();

我从另一个类似的 Activity 中调用它。

            if((getResources().getConfiguration().screenLayout &
Configuration.SCREENLAYOUT_SIZE_NORMAL) ==
Configuration.SCREENLAYOUT_SIZE_NORMAL){
Intent intent = new Intent(ShiftPeriodActivity.this, SelectIntervalActivity.class);
intent.putExtra("intervalHr", speriod.intervalHr);
intent.putExtra("intervalMin", speriod.intervalMin);
startActivityForResult(intent, 1);
} else {
FragmentManager fm = getSupportFragmentManager();
intervalDialog = new SelectTimeIntervalDialogFragment();
intervalDialog.setHrMin(speriod.intervalHr, speriod.intervalMin);
intervalDialog.show(fm, "interval_fragment");
}

我有两个条件。当屏幕尺寸正常时,它调用包含 fragment 对话框的 Activity 。否则,它调用弹出对话框。当它调用弹出对话框时出现异常。它说 requestFeature() 必须在添加内容之前调用。我可以这样使用吗?我想知道如何克服这个问题。

谢谢。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com