{"id":522,"date":"2017-09-17T00:33:27","date_gmt":"2017-09-16T15:33:27","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2017\/09\/17\/android_fragment_1\/"},"modified":"2017-09-17T00:33:27","modified_gmt":"2017-09-16T15:33:27","slug":"android_fragment_1","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2017\/09\/17\/android_fragment_1\/","title":{"rendered":"Android Fragment\u3092\u52d5\u7684\u306b\u4f5c\u6210\u3059\u308b\u30b5\u30f3\u30d7\u30eb"},"content":{"rendered":"<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Android-Fragment_4CB\/fragment_dynamic.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"173\" height=\"321\" title=\"fragment_dynamic\" style=\"display: inline; background-image: none;\" alt=\"fragment_dynamic\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Android-Fragment_4CB\/fragment_dynamic_thumb.jpg\" border=\"0\"><\/a><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2017\/09\/13\/android_fragment\">\u9759\u7684\u306b\u5b9a\u7fa9\u3057\u305f\u3001Fragment<\/a> \u3092\u52d5\u7684\u306b\u8ffd\u52a0\u3059\u308b\u3088\u3046\u3001\u5909\u66f4\u3059\u308b\u3002<a title=\"https:\/\/github.com\/pppiroto\/KaigiUtil\/tree\/92bb627ae2256e10008f17b501f022a75806c13c\" href=\"https:\/\/github.com\/pppiroto\/KaigiUtil\/tree\/92bb627ae2256e10008f17b501f022a75806c13c\">https:\/\/github.com\/pppiroto\/KaigiUtil\/tree\/92bb627ae2256e10008f17b501f022a75806c13c<\/a><\/p>\n<h2>1.Activity<\/h2>\n<p>Fragment\u3092\u914d\u7f6e\u3059\u308b\u30ec\u30a4\u30a2\u30a6\u30c8<\/p>\n<h3>1.1 \u30ec\u30a4\u30a2\u30a6\u30c8<\/h3>\n<pre class=\"prettyprint linenums\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;android.support.constraint.ConstraintLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"\r\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    tools:context=\"info.typea.kaigiutil.ContentActivity\"&gt;\r\n\r\n    &lt;LinearLayout\r\n        android:id=\"@+id\/content_fragment_container\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"match_parent\"\r\n        android:orientation=\"horizontal\"&gt;\r\n    &lt;\/LinearLayout&gt;\r\n\r\n&lt;\/android.support.constraint.ConstraintLayout&gt;\r\n<\/pre>\n<h3>1.2 Fragment\u3092\u8aad\u307f\u8fbc\u3080Activity<\/h3>\n<pre class=\"prettyprint linenums\">package info.typea.kaigiutil;\r\n\r\nimport android.os.Bundle;\r\nimport android.support.v4.app.FragmentManager;\r\nimport android.support.v7.app.AppCompatActivity;\r\n\r\npublic class ContentActivity extends AppCompatActivity {\r\n\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.activity_content);\r\n\r\n        FragmentManager fragmentManager = getSupportFragmentManager();\r\n        fragmentManager.beginTransaction()\r\n                .add(R.id.content_fragment_container,\r\n                    SleepDefenderFragment.newInstance(\"test message\"))\r\n                .addToBackStack(null)\r\n                .commit();\r\n    }\r\n}\r\n<\/pre>\n<h2>2.\u547c\u3073\u51fa\u3055\u308c\u308bFragment<\/h2>\n<h3>2.1 \u30ec\u30a4\u30a2\u30a6\u30c8<\/h3>\n<pre class=\"prettyprint linenums\">&lt;FrameLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    tools:context=\"info.typea.kaigiutil.SleepDefenderFragment\"&gt;\r\n\r\n    &lt;TextView\r\n        android:id=\"@+id\/txt_message\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"match_parent\"\r\n        android:text=\"TEST\" \/&gt;\r\n\r\n&lt;\/FrameLayout&gt;<\/pre>\n<h3>2.2 Fratment<\/h3>\n<pre class=\"prettyprint linenums\">package info.typea.kaigiutil;\r\n\r\nimport android.os.Bundle;\r\nimport android.support.annotation.Nullable;\r\nimport android.support.v4.app.Fragment;\r\nimport android.view.LayoutInflater;\r\nimport android.view.View;\r\nimport android.view.ViewGroup;\r\nimport android.widget.TextView;\r\n\r\n\r\npublic class SleepDefenderFragment extends Fragment {\r\n    private static final String ARG_MSG = \"message\";\r\n\r\n    public SleepDefenderFragment() {\r\n    }\r\n\r\n    public static SleepDefenderFragment newInstance(String message) {\r\n        SleepDefenderFragment fragment = new SleepDefenderFragment();\r\n        Bundle args = new Bundle();\r\n        args.putString(ARG_MSG, message);\r\n        fragment.setArguments(args);\r\n        return fragment;\r\n    }\r\n\r\n    @Override\r\n    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {\r\n        super.onCreateView(inflater, container, savedInstanceState);\r\n        return inflater.inflate(R.layout.fragment_sleep_defender, container, false);\r\n    }\r\n\r\n    @Override\r\n    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\r\n        super.onViewCreated(view, savedInstanceState);\r\n        TextView txtMessage = (TextView)view.findViewById(R.id.txt_message);\r\n        txtMessage.setText(getArguments().getString(ARG_MSG));\r\n    }\r\n}<\/pre>\n<p><a href=\"https:\/\/www.amazon.co.jp\/Android%E3%82%A2%E3%83%97%E3%83%AA%E9%96%8B%E7%99%BA%E3%81%AE%E6%A5%B5%E6%84%8F-%E3%83%97%E3%83%AD%E5%93%81%E8%B3%AA%E3%82%92%E5%AE%9F%E7%8F%BE%E3%81%99%E3%82%8B%E3%81%9F%E3%82%81%E3%81%AE%E7%8F%BE%E5%A0%B4%E3%81%AE%E7%9F%A5%E6%81%B5%E3%81%A8%E3%83%86%E3%82%AF%E3%83%8B%E3%83%83%E3%82%AF-%E6%9C%A8%E7%94%B0-%E5%AD%A6\/dp\/4774188174\/ref=as_li_ss_il?s=books&amp;ie=UTF8&amp;qid=1505575916&amp;sr=1-10&amp;keywords=android&amp;linkCode=li2&amp;tag=typea09-22&amp;linkId=b7169f2f72f1bc0cddc37d1f53e04454\" target=\"_blank\"><img decoding=\"async\" src=\"\/\/ws-fe.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&amp;ASIN=4774188174&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=typea09-22\" border=\"0\"><\/a><img loading=\"lazy\" decoding=\"async\" width=\"1\" height=\"1\" style=\"margin: 0px !important; border: currentcolor !important; border-image: none !important;\" alt=\"\" src=\"https:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=typea09-22&amp;l=li2&amp;o=9&amp;a=4774188174\" border=\"0\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9759\u7684\u306b\u5b9a\u7fa9\u3057\u305f\u3001Fragment \u3092\u52d5\u7684\u306b\u8ffd\u52a0\u3059\u308b\u3088\u3046\u3001\u5909\u66f4\u3059\u308b\u3002https:\/\/github.com\/pppiroto\/KaigiUtil\/tree\/92bb627ae2256e10008f17b501f022a758 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[39],"tags":[],"class_list":["post-522","post","type-post","status-publish","format-standard","hentry","category-android"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=522"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/522\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}