{"id":1246,"date":"2023-03-18T09:37:48","date_gmt":"2023-03-18T01:37:48","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1246"},"modified":"2023-04-29T09:30:23","modified_gmt":"2023-04-29T01:30:23","slug":"android-dialogfragment-lifecycle-show-oncreateview","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/18\/android-dialogfragment-lifecycle-show-oncreateview\/","title":{"rendered":"Android DialogFragment\u751f\u547d\u5468\u671fshow->onCreateView"},"content":{"rendered":"<p>DialogFragment.show\u663e\u793a\u7684\u751f\u547d\u5468\u671f\u662f\uff1a\u5148\u6267\u884cshow()\u65b9\u6cd5\uff0c\u518d\u6267\u884conCreateView()\u65b9\u6cd5\uff0c\u82e5\u6709\u5982\u4e0b\u64cd\u4f5c\uff1a<\/p>\n<pre><code class=\"language-java\">mActivityDialogFragment.show(((FragmentActivity) mActivity).getSupportFragmentManager(), &quot;dialog&quot;);\nmActivityDialogFragment.setDialogBackground(url);<\/code><\/pre>\n<p><!-- more --><\/p>\n<pre><code class=\"language-java\">@Override\npublic View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {\n    NLog.i(&quot;yezhou&quot;, &quot;ActivityDialogFragment.onCreateView&quot;);\n    return inflater.inflate(R.layout.layout_activity_dialog, container);\n}\n\n@Override\npublic void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\n    NLog.i(&quot;yezhou&quot;, &quot;ActivityDialogFragment.onViewCreated&quot;);\n    initView(view);\n    GlideImageLoader.loadViewBackground(getContext(), bgUrl, mLayoutActivityDialog);\n    super.onViewCreated(view, savedInstanceState);\n}\n\npublic void setDialogBackground(String url) {\n    NLog.i(&quot;yezhou&quot;, &quot;ActivityDialogFragment.setDialogBackground&quot;);\n    \/\/GlideImageLoader.loadViewBackground(getContext(), bgUrl, mLayoutActivityDialog);  \/\/mLayoutActivityDialog\u7a7a\u6307\u9488\u5f02\u5e38\n    bgUrl = url;\n}\n\n@Override\npublic void show(FragmentManager manager, String tag) {\n    NLog.i(&quot;yezhou&quot;, &quot;ActivityDialogFragment.show&quot;);\n    if (Build.VERSION.SDK_INT &gt; Build.VERSION_CODES.JELLY_BEAN) {\n        if (manager.isDestroyed())\n            return;\n    }\n    try {\n        super.show(manager, tag);\n    } catch (Exception e) {\n        e.printStackTrace();\n    }\n}<\/code><\/pre>\n<p>\u8f93\u51fa\u65e5\u5fd7<\/p>\n<pre><code>ActivityDialogFragment.show\nActivityDialogFragment.setDialogBackground\nActivityDialogFragment.onCreateView\nActivityDialogFragment.onViewCreated<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>DialogFragment.show\u663e\u793a\u7684\u751f\u547d\u5468\u671f\u662f\uff1a\u5148\u6267\u884cshow()\u65b9\u6cd5\uff0c\u518d\u6267\u884conCreateView [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[119],"tags":[216],"class_list":["post-1246","post","type-post","status-publish","format-standard","hentry","category-android-ui","tag-dialogfragment"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1246"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1246\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}