{"id":1269,"date":"2013-10-08T23:40:56","date_gmt":"2013-10-08T14:40:56","guid":{"rendered":"https:\/\/www.united-bears.co.jp\/blog\/?p=1269"},"modified":"2013-10-08T23:40:56","modified_gmt":"2013-10-08T14:40:56","slug":"android-%e3%81%ae-edittext-%e3%81%ae-ime-%e3%82%92%e5%88%b6%e5%be%a1%e3%81%99%e3%82%8b2","status":"publish","type":"post","link":"https:\/\/www.united-bears.co.jp\/blog\/archives\/1269","title":{"rendered":"Android \u306e EditText \u306e IME \u3092\u5236\u5fa1\u3059\u308b(2)"},"content":{"rendered":"<p><a href=\"https:\/\/www.united-bears.co.jp\/blog\/archives\/1194\" target=\"_blank\">\u524d\u56de<\/a>\u306f\u3001IME \u3092\u5236\u5fa1\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u4f5c\u6210\u3057\u305f\u3002\u4eca\u56de\u306f\u3001EditText \u306b\u30d5\u30a9\u30fc\u30ab\u30b9\u304c\u3042\u308b\u304b\u306a\u3044\u304b\u3067 IME \u306e\u8868\u793a\u3092\u5236\u5fa1\u3057\u3066\u307f\u308b\u3002\u76ee\u6a19\u306f\u3001<\/p>\n<ul>\n<li>EditText \u304c\u30d5\u30a9\u30fc\u30ab\u30b9\u3092\u5f97\u308b\u3068 IME \u304c\u8d77\u52d5<\/li>\n<li>EditText <strong>\u4ee5\u5916\u306e\u7b87\u6240<\/strong>\u3092\u30bf\u30c3\u30d7\u3059\u308b\u3068 IME \u304c\u7d42\u4e86<\/li>\n<\/ul>\n<p>\u3068\u3044\u3046\u52d5\u4f5c\u3060\u3002<\/p>\n<p>\u666e\u901a\u306b\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3057\u305f\u3060\u3051\u3060\u3068\u3001EditText \u4ee5\u5916\u306e\u7b87\u6240\u3092\u30bf\u30c3\u30d7\u3057\u3066\u3082 IME \u304c\u6d88\u3048\u306a\u3044\u3053\u3068\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u5c11\u3057\u5f37\u5f15\u306a\u30b3\u30fc\u30c9\u3092\u7528\u610f\u3057\u3066\u307f\u305f\u3002\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306f\u3001Context \u3068 EditText \u3092\u5f15\u6570\u3068\u3057\u3066\u6e21\u3059\u3053\u3068\u3092\u524d\u63d0\u306b\u3057\u3066\u3044\u308b\u3002showInputMethodEditor \u3084 hideInputMethodEditor \u306f\u3001\u524d\u56de\u4f5c\u6210\u3057\u305f\u30e1\u30bd\u30c3\u30c9\u3060\u3002<\/p>\n<pre>\r\npublic static void inputMethodEditorControl(final Context context,\r\n        final View view) {\r\n\r\n    \/\/ EditText \u3092\u30bf\u30c3\u30d7\u3057\u305f\u3089\u30d5\u30a9\u30fc\u30ab\u30b9\u3092\u6301\u3064\u3088\u3046\u306b\u3059\u308b\r\n    view.setOnClickListener(new View.OnClickListener() {\r\n        @Override\r\n        public void onClick(View v) {\r\n            if (!view.hasFocus()) {\r\n                view.setFocusable(true);\r\n                view.setFocusableInTouchMode(true);\r\n                view.requestFocus();\r\n            }\r\n        }\r\n    });\r\n    \r\n    \/\/ EditText \u306e\u30d5\u30a9\u30fc\u30ab\u30b9\u306e\u5909\u5316\u306b\u5fdc\u3058\u3066 IME \u3092\u5236\u5fa1\r\n    final View.OnFocusChangeListener listener = view\r\n            .getOnFocusChangeListener();\r\n    view.setOnFocusChangeListener(new View.OnFocusChangeListener() {\r\n        @Override\r\n        public void onFocusChange(View v, boolean hasFocus) {\r\n            \/\/ \u30d5\u30a9\u30fc\u30ab\u30b9\u3092\u6301\u3063\u305f\u3089\u8868\u793a\r\n            if (hasFocus) {\r\n                showInputMethodEditor(context, view);\r\n            }\r\n            \/\/ \u30d5\u30a9\u30fc\u30ab\u30b9\u3092\u5931\u3063\u305f\u3089\u975e\u8868\u793a\u306b\r\n            else {\r\n                hideInputMethodEditor(context, view);\r\n            }\r\n            if (null != listener) {\r\n                listener.onFocusChange(v, hasFocus);\r\n            }\r\n        }\r\n    });\r\n\r\n    \/\/ EditText \u306e\u4e0a\u4f4d\u306e View \u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3089 EditText \u306e\u30d5\u30a9\u30fc\u30ab\u30b9\u3092\u5916\u3059\r\n    ViewParent parent = view.getParent();\r\n    while (parent instanceof View) {\r\n        View v = (View) parent;\r\n        v.setOnClickListener(new View.OnClickListener() {\r\n            @Override\r\n            public void onClick(View v) {\r\n                for (final View view : views) {\r\n                    view.setFocusable(false);\r\n                    view.setFocusableInTouchMode(false);\r\n                    view.clearFocus();\r\n                }\r\n            }\r\n        });\r\n        parent = v.getParent();\r\n    }\r\n}\r\n<\/pre>\n<p>\u30b3\u30fc\u30c9\u306e\u5185\u5bb9\u306f\u3001\u30b3\u30e1\u30f3\u30c8\u3092\u8ffd\u52a0\u3057\u3066\u8aac\u660e\u3057\u3066\u307f\u305f\u3002\u6700\u5f8c\u306e\u300cEditText \u306e\u4e0a\u4f4d\u306e View \u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3089 EditText \u306e\u30d5\u30a9\u30fc\u30ab\u30b9\u3092\u5916\u3059\u300d\u306e\u51e6\u7406\u306f\u3001EditText \u306e\u4e0a\u4f4d\u306e View \u3092\u305f\u3069\u3063\u3066\u3044\u3063\u3066\u3001\u3069\u308c\u304b\u304c\u30bf\u30c3\u30d7\u3055\u308c\u305f\u3089 EditText \u3092\u30d5\u30a9\u30fc\u30ab\u30b9\u3067\u304d\u306a\u3044\u3088\u3046\u306b\u5909\u66f4\u3057\u3066\u3044\u308b\u3002\u305f\u3060\u3001\u3053\u3093\u306a\u51e6\u7406\u304c\u672c\u5f53\u306b\u5fc5\u8981\u306a\u306e\u304b\u7591\u554f\u3060\u3002\u308f\u3056\u308f\u3056 View \u306e\u968e\u5c64\u3092\u305f\u3069\u3063\u3066\u51e6\u7406\u3092\u8ffd\u52a0\u3057\u3066\u3044\u304b\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3068\u3057\u305f\u3089\u3001\u7d50\u69cb\u9762\u5012\u3060\u3002\u4f55\u304b\u9593\u9055\u3048\u3066\u3044\u308b\u304b\u3001\u52d8\u9055\u3044\u3057\u3066\u3044\u308b\u304b\u30fb\u30fb\u30fb\u8a2d\u5b9a\u3092\u5fd8\u308c\u3066\u3044\u308b\u3088\u3046\u306a\u6c17\u304c\u3059\u308b\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u52d5\u3044\u3066\u3044\u308b\u306e\u3067\u4f7f\u3063\u3066\u307f\u3066\u3044\u308b(\u3082\u3063\u3068\u3082\u3001\u5b9f\u969b\u306e\u30b3\u30fc\u30c9\u306f\u5c11\u3057\u9055\u3046\u304c)\u3002\u3088\u3044\u65b9\u6cd5\u304c\u898b\u3064\u304b\u3063\u305f\u3089\u3001\u300cAndroid \u306e EditText \u306e IME \u3092\u5236\u5fa1\u3059\u308b(3)\u300d\u3067\u5831\u544a\u3057\u305f\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306f\u3001IME \u3092\u5236\u5fa1\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u4f5c\u6210\u3057\u305f\u3002\u4eca\u56de\u306f\u3001EditText \u306b\u30d5\u30a9\u30fc\u30ab\u30b9\u304c\u3042\u308b\u304b\u306a\u3044\u304b\u3067 IME \u306e\u8868\u793a\u3092\u5236\u5fa1\u3057\u3066\u307f\u308b\u3002\u76ee\u6a19\u306f\u3001 EditText \u304c\u30d5\u30a9\u30fc\u30ab\u30b9\u3092\u5f97\u308b\u3068 IME \u304c\u8d77\u52d5 EditText \u4ee5\u5916 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3],"tags":[],"class_list":["post-1269","post","type-post","status-publish","format-standard","hentry","category-android","category-android-develop"],"_links":{"self":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/1269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/comments?post=1269"}],"version-history":[{"count":4,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/1269\/revisions"}],"predecessor-version":[{"id":1273,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/1269\/revisions\/1273"}],"wp:attachment":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/media?parent=1269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/categories?post=1269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/tags?post=1269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}