{"id":4094,"date":"2016-07-19T10:00:01","date_gmt":"2016-07-19T01:00:01","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=4094"},"modified":"2016-07-15T18:58:19","modified_gmt":"2016-07-15T09:58:19","slug":"%e6%96%b0%e4%ba%ba%e6%88%90%e9%95%b7%e8%a8%98%e9%8c%b24th","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/4094","title":{"rendered":"\u65b0\u4eba\u6210\u9577\u8a18\u93324th"},"content":{"rendered":"<p style=\"text-align: center;\">\u3053\u3093\u306b\u3061\u306f\u3001Android\u958b\u767a\u30d7\u30ed\u30b0\u30e9\u30de\u306epoppy\u3067\u3059<\/p>\n<p><a href=\"\/appnews\/archives\/4034\" target=\"_blank\" rel=\"noopener\">\u524d\u56de\u306e\u8a18\u4e8b<\/a>\u3067\u306f\u3001<br \/>\nListView\u306b\u304a\u3051\u308b\u52d5\u7684\u306aView\u306e\u751f\u6210\u3092\u3054\u7d39\u4ecb\u3044\u305f\u3057\u307e\u3057\u305f<\/p>\n<p>\u4eca\u56de\u306f\u3001Fragment\u306b\u3064\u3044\u3066\u8a18\u4e8b\u306b\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059<\/p>\n<p><!--more--><\/p>\n<p>\u3067\u306f\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u5185\u5bb9\u3067\u3055\u3063\u305d\u304f\u3044\u304d\u307e\u3059\u3088\uff5e<br \/>\n\u3010Activity\u306e\u30ec\u30a4\u30a2\u30a6\u30c8\u3011<br \/>\n\u3010\u5b9f\u88c5\u7de8(Fragment\u30af\u30e9\u30b9\u306e\u4f5c\u6210)\u3011<br \/>\n\u3010\u5b9f\u88c5\u7de8(Activity\u304b\u3089\u306e\u547c\u3073\u51fa\u3057)\u3011<br \/>\n\u3010\u7d42\u308f\u308a\u306b\u3011<\/p>\n<h4>Activity\u306e\u30ec\u30a4\u30a2\u30a6\u30c8<\/h4>\n<p>\u3055\u3055\u3063\u3068MainActivity\u306e\u30ec\u30a4\u30a2\u30a6\u30c8\u3092\u7d39\u4ecb\u3057\u307e\u3059<br \/>\nTextView\u3067\u30bf\u30d6\u3063\u307d\u3044\u3082\u306e\u30923\u3064\u7528\u610f\u3057\u307e\u3059<br \/>\n\u30bf\u30c3\u30d7\u3055\u308c\u305f\u3089FrameLayout\u306e\u4e2d\u304c\u5909\u5316\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u304d\u307e\u3059<\/p>\n<pre style=\"border: dashed #000000 2px; padding-left: 5px;\"><code>\r\n&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;LinearLayout 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    android:padding=\"20dp\"\r\n    tools:context=\".MainActivity\"\r\n    android:orientation=\"vertical\"&gt;\r\n\r\n    &lt;LinearLayout\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:orientation=\"horizontal\"&gt;\r\n\r\n        &lt;TextView android:id=\"@+id\/tab1\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_margin=\"20dp\"\r\n            android:text=\"\u30bf\u30d61\"\r\n            android:onClick=\"onClick\"\/&gt;\r\n\r\n        &lt;TextView android:id=\"@+id\/tab2\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_margin=\"20dp\"\r\n            android:text=\"\u30bf\u30d62\"\r\n            android:onClick=\"onClick\"\/&gt;\r\n\r\n        &lt;TextView android:id=\"@+id\/tab3\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_margin=\"20dp\"\r\n            android:text=\"\u30bf\u30d63\"\r\n            android:onClick=\"onClick\"\/&gt;\r\n    &lt;\/LinearLayout&gt;\r\n\r\n    &lt;FrameLayout android:id=\"@+id\/fragment_frame\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"match_parent\"&gt;\r\n    &lt;\/FrameLayout&gt;\r\n\r\n&lt;\/LinearLayout&gt;\r\n<\/code>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h4>\u5b9f\u88c5\u7de8(Fragment\u30af\u30e9\u30b9\u306e\u4f5c\u6210)<\/h4>\n<p>\u3053\u3053\u304b\u3089\u306f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u304a\u6642\u9593\u3067\u3059<br \/>\nFragment\u30af\u30e9\u30b9\u306e\u5b9f\u88c5\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u3066\u3044\u304d\u307e\u3059<\/p>\n<p>Fragment\u3092\u7d99\u627f\u3057\u305f\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059<br \/>\n\u3053\u306e\u30af\u30e9\u30b9\u3067\u76ee\u7684\u306e\u30ec\u30a4\u30a2\u30a6\u30c8\u3092\u751f\u6210\u3057\u307e\u3059<br \/>\nInflater\u3092\u4f7f\u7528\u3057\u3066xml\u304b\u3089\u30ec\u30a4\u30a2\u30a6\u30c8\u3092\u53d6\u5f97\u3057\u305f\u308a\u3001<br \/>\n\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\u3057\u3066\u623b\u308a\u5024\u3068\u3059\u308b\u3053\u3068\u3067\u3001\u52d5\u7684\u306b\u751f\u6210\u3057\u305f\u308a\u81ea\u7531\u306b\u3067\u304d\u307e\u3059<\/p>\n<pre style=\"border: dashed #000000 2px; padding-left: 5px;\"><code>\r\npublic class myFragment extends Fragment{\r\n\t\/\/\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3001\u7279\u306b\u306a\u306b\u3082\u3057\u306a\u3044\r\n\tpublic myFragment(){}\r\n\r\n\t\/\/commit\u6642\u306b\u547c\u3070\u308c\u308b(View\u304c\u63cf\u753b\u3055\u308c\u308b\u6642)\r\n\tpublic View onCreateView(LayoutInflater inflater, ViewGroup container, \r\n\t\t\t\t\t\tBundle bundle){\r\n\t\t\/\/inflate(int resource, ViewGroup root, boolean attachToRoot)\r\n\t\t\/\/inflate(\u633f\u5165\u3057\u305f\u3044\u30ec\u30a4\u30a2\u30a6\u30c8,\u89aa\u3068\u306a\u308bViewGroup, View\u306eroot\u3092\u53d6\u308b\u304b\u3069\u3046\u304b\uff1f)\r\n\t\tView v= inflater.inflate(R.layout.contentlayout,container,false);\r\n\t\t\/\/\u53d6\u5f97\u3057\u305fView\u3092\u8fd4\u3059\r\n\t\treturn v;\r\n\t}\r\n}\r\n<\/code>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u4f8b\u3067\u306f\u3001View\u3092\u53d6\u5f97\u3057\u3066\u304b\u3089\u3059\u3050\u306b\u7d42\u4e86\u3057\u307e\u3057\u305f<br \/>\n<strong>View\u306b\u624b\u3092\u52a0\u3048\u306a\u3044\u3088\u3046\u306a\u3089<\/strong><br \/>\nreturn inflater.inflate(&#8230;);\u3068\u3057\u3066\u3082\u5927\u4e08\u592b\u3002\u3080\u3057\u308d\u3053\u3061\u3089\u306a\u30891\u884c\u3067\u8a18\u8ff0\u3067\u304d\u308b<br \/>\n\u3067\u3082\u3001\u624b\u3092\u52a0\u3048\u306a\u3044\u306a\u3089\u305d\u3082\u305d\u3082Fragment\u3067\u547c\u3076\u5fc5\u8981\u306f\u3042\u308b\u306e\u304b\u3069\u3046\u304b<br \/>\n\u77ed\u3044\u306a\u3089Activity\u5185\u3067\u8a18\u8ff0\u3057\u305f\u65b9\u304c\u3044\u3044\u6c17\u3082\u3059\u308b<\/p>\n<p><strong>\u624b\u3092\u52a0\u3048\u308b\u306a\u3089(xml\u306e\u30ec\u30a4\u30a2\u30a6\u30c8\u3092\u4f7f\u7528)<\/strong><br \/>\n\u578b \u5909\u6570\u540d = (\u578b)v.findViewById();\u3067<br \/>\n\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u751f\u6210\u304c\u3067\u304d\u308b\u306e\u3067\u3001\u5185\u5bb9\u3092\u7de8\u96c6\u3057\u3066\u3044\u3053\u3046<\/p>\n<p><strong>\u624b\u3092\u52a0\u3048\u308b\u306a\u3089(\u52d5\u7684\u306b\u751f\u6210)<\/strong><br \/>\n\u578b \u5909\u6570\u540d = new \u578b<br \/>\n\u3067\u751f\u6210\u3057\u305f\u3044\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u53d6\u5f97\u3057\u3066\u3044\u304f<br \/>\n\u6700\u5f8c\u306b\u623b\u308a\u306b\u3057\u305f\u3089\u554f\u984c\u306a\u3057<\/p>\n<p>inflate\u30e1\u30bd\u30c3\u30c9\u306f\u5f15\u6570\u304c2\u3064\u306einflate(int resource, ViewGroup root)\u3082\u5b58\u5728\u3059\u308b<br \/>\n\u305d\u308c\u305e\u308c\u306e\u5f15\u6570\u306b\u5909\u5316\u3092\u4e0e\u3048\u3066\u5b9f\u884c\u3057\u305f\u7d50\u679c\u3001\u5f97\u3089\u308c\u308bView\u306e\u5024\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u305f<\/p>\n<table>\n<tbody>\n<tr>\n<th><\/th>\n<th>\u5f15\u6570\u304c2\u3064<\/th>\n<th>\u5f15\u6570\u304c3\u3064(true)<\/th>\n<th>\u5f15\u6570\u304c3\u3064(false)<\/th>\n<\/tr>\n<tr>\n<th>root\u304c\u6709<\/th>\n<td>root\u306b\u6307\u5b9a\u3057\u305fView<\/td>\n<td>source\u306b\u6307\u5b9a\u3057\u305fView<\/td>\n<td>root\u306b\u6307\u5b9a\u3057\u305fView<\/td>\n<\/tr>\n<tr>\n<th>root\u304cnull<\/th>\n<td>source\u306b\u6307\u5b9a\u3057\u305fView<\/td>\n<td>source\u306b\u6307\u5b9a\u3057\u305fView<\/td>\n<td>source\u306b\u6307\u5b9a\u3057\u305fView<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u9069\u5207\u306a\u5834\u9762\u3067\u306e\u4f7f\u3044\u5206\u3051\u306f\u307e\u3060\u7406\u89e3\u3067\u304d\u3066\u3044\u306a\u3044\u3067\u3059\u304c\u3001<br \/>\n\u4eca\u56de\u306fsource\u3067\u3042\u308bView\u3092\u53d6\u5f97\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046<\/p>\n<h4>\u5b9f\u88c5\u7de8(Activity\u304b\u3089\u306e\u547c\u3073\u51fa\u3057)<\/h4>\n<p>Activity\u306e\u7d39\u4ecb\u3092\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046<\/p>\n<pre style=\"border: dashed #000000 2px; padding-left: 5px;\"><code>\r\npublic class MainActivity extends AppCompatActivity implements View.OnClickListener{\r\n\r\n\t@Override\r\n\tprotected void onCreate(Bundle savedInstanceState) {\r\n\t\tsuper.onCreate(savedInstanceState);\r\n\t\trequestWindowFeature(Window.FEATURE_NO_TITLE);\r\n\t\t\/\/\u521d\u56de\u8868\u793a\u306eFragment\u3092\u8868\u793a\r\n\t\tsetFragment(new topFragment());\r\n\t\tsetContentView(R.layout.activity_main);\r\n\t}\r\n\t\/\/\u5404\u30c6\u30ad\u30b9\u30c8\u3092\u30af\u30ea\u30c3\u30af\u6642\u306e\u30a4\u30d9\u30f3\u30c8\r\n\tpublic void onClick(View v){\r\n\t\tswitch (v.getId()){\r\n\t\t\tcase R.id.tab1:\r\n\t\t\t\tsetFragment(new myFragment());\r\n\t\t\t\tbreak;\r\n\t\t\tcase R.id.tab2:\r\n\t\t\t\tsetFragment(new my2Fragment());\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t\/\/Fragment\u8868\u793a\u306e\u30e1\u30bd\u30c3\u30c9\r\n\tprivate void setFragment(Fragment fragment){\r\n\t\t\/\/\u30ec\u30a4\u30a2\u30a6\u30c8\u306e\u5207\u308a\u66ff\u3048\u3092\u884c\u3046\r\n\t\tFragmentTransaction ft = getFragmentManager().beginTransaction();\r\n\t\t\/\/\u3069\u306e\u30ec\u30a4\u30a2\u30a6\u30c8\u306b\u8ffd\u52a0\u3059\u308b\u304b\u3001\u3059\u3067\u306bFragment\u304c\u5b58\u5728\u3059\u308c\u3070\u524a\u9664\u3057\u3066\u304b\u3089\u8ffd\u52a0\u3059\u308b\r\n\t\tft.replace(R.id.fragment_frame, fragment);\r\n\t\t\/\/Fragment\u306e\u9077\u79fb\u306e\u4ed5\u65b9\r\n\t\tft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);\r\n\t\t\/\/\u5b9f\u969b\u306b\u8868\u793a\r\n\t\tft.commit();\r\n\t}\r\n}\r\n<\/code><\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u5b9f\u88c5\u3057\u307e\u3057\u305f\u3002<br \/>\nFragment\u306fcommit\u3092\u3057\u306a\u3044\u3068\u8868\u793a\u3055\u308c\u306a\u3044\u306e\u3067\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059<\/p>\n<h4>\u7d42\u308f\u308a\u306b<\/h4>\n<p>\u524d\u56de\u306eListView\u3092\u52d5\u7684\u306b\u751f\u6210\u3059\u308b\u3088\u308a\u306f\u7406\u89e3\u3057\u3084\u3059\u304b\u3063\u305f\u3067\u3059<br \/>\nListView\u3068Fragment\u3001\u3069\u3061\u3089\u3082\u3088\u304f\u4f7f\u3046\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u3057\u3063\u304b\u308a\u3068\u899a\u3048\u3066\u304a\u304d\u305f\u3044\u3067\u3059<\/p>\n<p>\u6700\u8fd1\u306f\u3001Intent\u3084Service\u306b\u89e6\u308c\u308b\u6a5f\u4f1a\u304c\u3042\u308a\u307e\u3057\u305f\u304c\u3001\u6b63\u76f4\u96e3\u3057\u3044\u3067\u3059<br \/>\n\u65e9\u3044\u3046\u3061\u306b\u52c9\u5f37\u3059\u308b\u306e\u3067\u3001\u8fd1\u3044\u3046\u3061\u306b\u8a18\u4e8b\u306b\u3057\u305f\u3044\u3068\u8003\u3048\u3066\u3044\u307e\u3059<br \/>\n\u307e\u305f\u3001Object\u6307\u5411\u3078\u306e\u7406\u89e3\u3082\u4f4e\u3044\u306e\u304c\u898b\u53d7\u3051\u3089\u308c\u308b\u6240\u304c\u591a\u3005\u3042\u308a\u307e\u3057\u305f<br \/>\n\u305d\u306e\u305f\u3081\u3001Object\u6307\u5411\u306e\u3053\u3068\u3092\u3057\u3063\u304b\u308a\u3068\u52c9\u5f37\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u305d\u3046\u3067\u3059<\/p>\n<p>\u8a18\u4e8b\u306e\u30cd\u30bf\u304c\u8c4a\u5bcc\u306a\u3046\u3061\u306f\u307e\u3060\u307e\u3060\u672a\u719f\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u5fc5\u6b7b\u306b\u52c9\u5f37\u3059\u308b\u306e\u307f\u3067\u3059\uff01<\/p>\n<p>\u4ee5\u4e0a\u3001\u706b\u66dc\u65e5\u62c5\u5f53\uff1apoppy\u304b\u3089\u3067\u3057\u305f<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/4094\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/4094\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"\u65b0\u4eba\u6210\u9577\u8a18\u93324th\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/4094\" data-text=\"\u65b0\u4eba\u6210\u9577\u8a18\u93324th\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/4094\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/4094\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001Android\u958b\u767a\u30d7\u30ed\u30b0\u30e9\u30de\u306epoppy\u3067\u3059 \u524d\u56de\u306e\u8a18\u4e8b\u3067\u306f\u3001 ListView\u306b\u304a\u3051\u308b\u52d5\u7684\u306aView\u306e\u751f\u6210\u3092\u3054\u7d39\u4ecb\u3044\u305f\u3057\u307e\u3057\u305f \u4eca\u56de\u306f\u3001Fragment\u306b\u3064\u3044\u3066\u8a18\u4e8b\u306b\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[27,12],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/4094"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=4094"}],"version-history":[{"count":47,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/4094\/revisions"}],"predecessor-version":[{"id":4185,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/4094\/revisions\/4185"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=4094"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=4094"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=4094"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}