Notice: 函数 WP_Scripts::localize 的调用方法不正确$l10n 参数必须是一个数组。若要将任意数据传递给脚本,请改用 wp_add_inline_script() 函数。 请查阅调试 WordPress来获取更多信息。 (这个消息是在 5.7.0 版本添加的。) in /data/www/appblog/wp-includes/functions.php on line 6131

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
上一篇 RecyclerView GridLayoutManager实现复杂的列数变化的布局
下一篇 Android插件化之startActivity hook实现登录拦截