{"id":577,"date":"2016-12-04T09:20:44","date_gmt":"2016-12-04T00:20:44","guid":{"rendered":"http:\/\/blue-bear.jp\/kb\/?p=577"},"modified":"2016-12-21T06:53:27","modified_gmt":"2016-12-20T21:53:27","slug":"android-must-implement-onfragmentinteractionlistener%e3%82%a8%e3%83%a9%e3%83%bc","status":"publish","type":"post","link":"https:\/\/blue-bear.jp\/kb\/android-must-implement-onfragmentinteractionlistener%e3%82%a8%e3%83%a9%e3%83%bc\/","title":{"rendered":"[android] must implement OnFragmentInteractionListener\u30a8\u30e9\u30fc"},"content":{"rendered":"<h2>must implement OnFragmentInteractionListener\u30a8\u30e9\u30fc<\/h2>\n<p>recyclerView\u3067Item\u306e\u30bf\u30c3\u30d7\u51e6\u7406\u3092\u5b9f\u88c5\u3059\u308b\u3068<br \/>\nmust implement OnFragmentInteractionListener\u30a8\u30e9\u30fc<br \/>\n\u3082\u3057\u304f\u306f<br \/>\nmust implement OnListFragmentInteractionListener\u30a8\u30e9\u30fc<br \/>\n\u304c\u3067\u308b\u3053\u3068\u304c\u3042\u308b<\/p>\n<p>\u3053\u3061\u3089\u306f<br \/>\nfragment\u306e<\/p>\n<pre>\r\n@Override\r\n    public void onAttach(Context context) {\r\n        super.onAttach(context);\r\n        if (context instanceof OnListFragmentInteractionListener) {\r\n            mListener = (OnListFragmentInteractionListener) context;\r\n        } else {\r\n            throw new RuntimeException(context.toString()\r\n                    + \" must implement OnListFragmentInteractionListener\");\r\n        }\r\n    }\r\n<\/pre>\n<p>\u304c\u53cd\u5fdc\u3057\u3066\u3044\u308b\u305f\u3081\u3067\u3042\u308b<br \/>\n\u8981\u306f\u89aa\u306e\u3053\u306eFragment\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u308b\u89aaActivity\u306bOnListFragmentInteractionListener\u3092\u7d99\u627f\u3057\u3066\u3044\u306a\u3044\u3053\u3068\u304c\u7406\u7531<\/p>\n<p>\u306a\u306e\u3067Activity\u306bOnListFragmentInteractionListener\u3092\u7d99\u627f\u3057\u3066\u3042\u3052\u308c\u3070\u826f\u3044<\/p>\n<p>\u89aaActivity<\/p>\n<pre>\r\npublic class MainActivity extends AppCompatActivity implements ItemFragment.OnListFragmentInteractionListener {\r\n\r\n\u30fb\u30fb\u30fb\r\n\r\n\r\n}\r\n<\/pre>\n<p>\uff0aItemFragment\u3068\u3044\u3046Fragment\u306bOnListFragmentInteractionListener\u3068\u3044\u3046interface\u304c\u5b9f\u88c5\u3055\u308c\u3066\u3044\u308b\u5fc5\u8981\u304c\u3042\u308b<\/p>\n<p>\u307e\u305finterface\u3092\u7d99\u627f\u3057\u305f\u6642\u306b\u300c\u95a2\u6570\u304c\u66f8\u304b\u308c\u3066\u3044\u306a\u3044\u300d\u307f\u305f\u3044\u306a\u30a8\u30e9\u30fc\u304c\u8868\u793a\u3055\u308c\u308b\u5834\u5408\u306f\u3001\u7d99\u627f\u3057\u305fInterface\u304c\u6301\u3063\u3066\u3044\u308b\u95a2\u6570\u3092Activity\u306boverRide\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u3061\u3083\u3093\u3068Interface\u304c\u6301\u3063\u3066\u3044\u308b\u95a2\u6570\u3092\u3059\u3079\u3066overRide\u3059\u308b\u3053\u3068<\/p>\n<p>\u89aaActivity<\/p>\n<pre>\r\npublic class MainActivity extends AppCompatActivity implements ItemFragment.OnListFragmentInteractionListener {\r\n\r\n\/\/onListFragmentInteraction interface\u306e\u95a2\u6570\u300conListFragmentInteraction\u300d\u3092overRide\r\n@Override\r\n    public void onListFragmentInteraction(DummyContent.Dummy uri){\r\n        \/\/you can leave it empty\r\n        switch (uri.id){\r\n            case \"0\":\r\n                \/\/\u51e6\u7406\r\n                break;\r\n            case \"1\":\r\n                \/\/\u51e6\u7406\r\n                break;\r\n            default:\r\n        }\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>must implement OnFra<\/p>\n","protected":false},"author":1,"featured_media":383,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[46,31],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/577"}],"collection":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/comments?post=577"}],"version-history":[{"count":2,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/577\/revisions"}],"predecessor-version":[{"id":579,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/577\/revisions\/579"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media\/383"}],"wp:attachment":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media?parent=577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/categories?post=577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/tags?post=577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}