Android DialogFragment生命周期show->onCreateView
DialogFragment.show显示的生命周期是:先执行show()方法,再执行onCreateView()方法,若有如下操作:
mActivityDialogFragment.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "dialog");
mActivityDialogFragment.setDialogBackground(url);
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
NLog.i("yezhou", "ActivityDialogFragment.onCreateView");
return inflater.inflate(R.layout.layout_activity_dialog, container);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
NLog.i("yezhou", "ActivityDialogFragment.onViewCreated");
initView(view);
GlideImageLoader.loadViewBackground(getContext(), bgUrl, mLayoutActivityDialog);
super.onViewCreated(view, savedInstanceState);
}
public void setDialogBackground(String url) {
NLog.i("yezhou", "ActivityDialogFragment.setDialogBackground");
//GlideImageLoader.loadViewBackground(getContext(), bgUrl, mLayoutActivityDialog); //mLayoutActivityDialog空指针异常
bgUrl = url;
}
@Override
public void show(FragmentManager manager, String tag) {
NLog.i("yezhou", "ActivityDialogFragment.show");
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
if (manager.isDestroyed())
return;
}
try {
super.show(manager, tag);
} catch (Exception e) {
e.printStackTrace();
}
}
输出日志
ActivityDialogFragment.show
ActivityDialogFragment.setDialogBackground
ActivityDialogFragment.onCreateView
ActivityDialogFragment.onViewCreated
版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/18/android-dialogfragment-lifecycle-show-oncreateview/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。
THE END
0
二维码
打赏
海报
Android DialogFragment生命周期show->onCreateView
DialogFragment.show显示的生命周期是:先执行show()方法,再执行onCreateView()方法,若有如下操作:
mActivityDialogFragment.show(((FragmentActivity) mAc……
文章目录
关闭
共有 0 条评论