{"id":957,"date":"2017-03-18T14:48:36","date_gmt":"2017-03-18T06:48:36","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=957"},"modified":"2017-03-18T14:48:36","modified_gmt":"2017-03-18T06:48:36","slug":"android%e5%9f%ba%e7%a1%80%e5%bc%80%e5%8f%91%e4%b9%8bfragment%e7%9a%84%e7%ae%80%e5%8d%95%e4%bd%bf%e7%94%a8%e9%9d%99%e6%80%81%e5%8a%a0%e8%bd%bd","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/android\/2017\/03\/18\/144836957.html","title":{"rendered":"Android\u57fa\u7840\u5f00\u53d1\u4e4bFragment\u7684\u7b80\u5355\u4f7f\u7528(\u9759\u6001\u52a0\u8f7d)"},"content":{"rendered":"<p>1\u3001\u521b\u5efaFragment\u7684\u5e03\u5c40\u6587\u4ef6\uff0c\u5982fragment_up.xml\uff1b<\/p>\n<pre line=\"1\" lang=\"java\"><?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\n    android:orientation=\"vertical\" android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:background=\"#FF0000\">\n    <TextView\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"Hello Fragment\"\n        android:textColor=\"#FFFFFF\"\/>\n\n<\/LinearLayout> <\/pre>\n<p>2\u3001\u521b\u5efaFragment\u7684\u5b50\u7c7b\uff0c\u5b9e\u73b0onCreateView()\u65b9\u6cd5\uff1b<\/p>\n<pre line=\"1\" lang=\"java\">package com.yusian.fragment;\n\n\nimport android.app.Fragment;\nimport android.os.Bundle;\nimport android.support.annotation.Nullable;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\n\n\/**\n * Created by Sian on 2017\/3\/18.\n *\/\n\npublic class UpFragment extends Fragment {\n    @Nullable\n    @Override\n    \/\/ \u76f8\u5f53\u4e8eActivity\u7684setContentView\uff1b\n    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {\n        return inflater.inflate(R.layout.fragment_up, container, false);\n    }\n}<\/pre>\n<p>3\u3001\u5728Activity\u7684\u5e03\u5c40\u6587\u4ef6\u4e2d\u6dfb\u52a0fragment\u6807\u7b7e<!--more--><\/p>\n<pre line=\"1\" lang=\"java\"><?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n    xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\"\n    android:weightSum=\"2\"\n    tools:context=\"com.yusian.fragment.MainActivity\">\n\n    <fragment\n        android:id=\"@+id\/fg_first\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"0dp\"\n        android:layout_weight=\"1\"\n        android:name=\"com.yusian.fragment.UpFragment\"\/>\n\n<\/LinearLayout><\/pre>\n<p>4\u3001\u6700\u7ec8\u6548\u679c<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.yusian.com\/blog\/wp-content\/uploads\/2017\/03\/20170318144727.jpg\" alt=\"\" width=\"360\" height=\"640\" class=\"alignnone size-full wp-image-960\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u521b\u5efaFragment\u7684\u5e03\u5c40\u6587\u4ef6\uff0c\u5982fragment_up.xml\uff1b 2\u3001\u521b\u5efaFragment\u7684\u5b50\u7c7b\uff0c\u5b9e\u73b0onCreateView()\u65b9\u6cd5\uff1b package com.yusian.fragment; import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; \/** * Created by Sian on 2017\/3\/18. *\/ public class UpFragment extends Fragment { @Nullable @Override \/\/ \u76f8\u5f53\u4e8eActivity\u7684setContentView\uff1b public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_up, container, false); } } 3\u3001\u5728Activity\u7684\u5e03\u5c40\u6587\u4ef6\u4e2d\u6dfb\u52a0fragment\u6807\u7b7e<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[33,20],"class_list":["post-957","post","type-post","status-publish","format-standard","hentry","category-android","tag-33","tag-basics"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=957"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/957\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}