{"id":56,"date":"2016-02-01T23:49:45","date_gmt":"2016-02-01T14:49:45","guid":{"rendered":"http:\/\/www.hundredapps.net\/?p=56"},"modified":"2017-11-10T09:52:13","modified_gmt":"2017-11-10T00:52:13","slug":"actionbar%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/www.hundredapps.net\/?p=56","title":{"rendered":"Actionbar\u306b\u3064\u3044\u3066"},"content":{"rendered":"<h2>ActionBar\u3068\u306f\uff1f<\/h2>\n<p>\u30ed\u30b4\u3001\u30dc\u30bf\u30f3\u3001\u30bf\u30d6\u306a\u3069\u3092\u7c21\u5358\u306b\u5b9f\u73fe\u3067\u304d\u308b\u30c4\u30fc\u30eb\u30d0\u30fc\u3067\u3059\u3002<\/p>\n<a href=\"http:\/\/tipstar.link\/wp-content\/uploads\/2014\/09\/actionbar-01.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-361\" src=\"http:\/\/tipstar.link\/wp-content\/uploads\/2014\/09\/actionbar-01.png\" alt=\"actionbar-01\" width=\"485\" height=\"731\" \/><\/a>\n<h2>ActionBar\u306b\u30e1\u30cb\u30e5\u30fc\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n<p>\u305d\u308c\u3067\u306f\u3001\u4e0a\u8a18\u306e\u30ad\u30e3\u30d7\u30c1\u30e3\u30fc\u306b\u3042\u3063\u305f\u3088\u3046\u306b\u3001\u691c\u7d22\u3001\u65b0\u898f\u8ffd\u52a0\u30e1\u30cb\u30e5\u30fc\u3092<br \/> \u8868\u793a\u3055\u305b\u308b\u3084\u308a\u65b9\u3092\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8 > app > src > main > res > menu\u306e\u4e0b\u306b\u3001<br \/> \u9069\u5f53\u306a\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u3064\u3051\u305fxml\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/> \u203b\u65e2\u306b\u3001\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u4f5c\u6210\u3067actionbar\u4ed8\u304d<br \/> \u3092\u9078\u629e\u3057\u3066\u3044\u308c\u3070\u3001Activity\u306e\u540d\u524d\u3068\u5bfe\u5fdc\u3057\u305fXML\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308b\u3068<br \/> \u601d\u3044\u307e\u3059\u306e\u3067\u305d\u3061\u3089\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<menu><\/menu>\n<p>icon\u3001title\u3001orderInCategory\u3001ShowAcAction\u306e\u9806\u306b\u3001 \u8aac\u660e\u3057\u3066\u884c\u304d\u307e\u3059\u3002 icon\u306f\u3001\u305d\u306e\u540d\u306e\u901a\u308a\u3001\u30e1\u30cb\u30e5\u30fc\u306e\u30a2\u30a4\u30b3\u30f3\u753b\u50cf\u306b\u306a\u308a\u307e\u3059\u3002 \u3053\u3053\u3067\u306f\u3001\u300candroid:drawable\/ic_menu_edit\u300d\u306f\u3001android\u306e\u30e9\u30a4\u30d6\u30e9\u30ea \u306b\u65e2\u306b\u7528\u610f\u3055\u308c\u3066\u3044\u308b\u3082\u306e\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002 \u81ea\u5206\u3067\u7528\u610f\u3057\u305f\u753b\u50cf\u306e\u5834\u5408\u306f\u3001android:\u306f\u3064\u3051\u305a\u306b\u3001 \u300c@drawable\/\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u540d\u300d\u3068\u306a\u308a\u307e\u3059\u3002 titile\u306f\u3001\u305d\u306e\u307e\u307e\u3067\u3001\u30a2\u30a4\u30b3\u30f3\u306e\u30bf\u30a4\u30c8\u30eb\u306b\u306a\u308a\u307e\u3059\u3002 orderInCategory\u306f\u3001\u30a2\u30a4\u30b3\u30f3\u304c\u8907\u6570\u3042\u308b\u5834\u5408\u306e\u91cd\u307f\u3065\u3051\u3068\u306a\u308a\u307e\u3059\u3002 \u6570\u5b57\u304c\u5927\u304d\u3044\u307b\u3046\u304c\u3001\u512a\u5148\u9806\u4f4d\u304c\u9ad8\u304f\u306a\u308a\u5148\u306b\u4e26\u3073\u307e\u3059\u3002 \u305d\u3057\u3066\u3001\u6700\u5f8c\u306eshowAsAction\u3067\u3059\u304c\u3001\u8457\u8005\u306f\u3001\u4e3b\u306b\u3001 3\u7a2e\u985e\u306e\u30bf\u30a4\u30d7\u3092\u4f7f\u3044\u5206\u3051\u3066\u3044\u307e\u3059\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<td>showAsAction<\/td>\n<td>\u5185\u5bb9<\/td>\n<\/tr>\n<tr>\n<td>never<\/td>\n<td>\u76f4\u63a5ActionBar\u306b\u8868\u793a\u3055\u305b\u306a\u3044<\/td>\n<\/tr>\n<tr>\n<td>ifRoom<\/td>\n<td>ActionBar\u306b\u8868\u793a\u30b9\u30da\u30fc\u30b9\u3042\u308c\u3070\u3001\u8868\u793a\u3055\u305b\u308b<\/td>\n<\/tr>\n<tr>\n<td>always<\/td>\n<td>ActionBar\u306b\u5e38\u306b\u8868\u793a\u3055\u305b\u308b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u305d\u308c\u3067\u306f\u3001\u6b21\u306f\u3001Activity\u5074\u304b\u3089\u3001\u5148\u307b\u3069\u8aac\u660e\u3057\u305fXML\u3092\u7528\u3044\u308a\u8868\u793a\u3055\u305b\u307e\u3059\u3002<br \/> \u307e\u305f\u3001\u30dc\u30bf\u30f3\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u5408\u3063\u305f\u969b\u306e\u7d44\u8fbc\u307f\u3082\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">public class ActionBarSampleActivity extends Activity {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_action_bar_sample);\n    }\n\n\n    \/**\n     \u30aa\u30d7\u30b7\u30e7\u30f3\u30e1\u30cb\u30e5\u30fc\u306e\u4f5c\u6210\u51e6\u7406\u306b\u306a\u308a\u307e\u3059\u3002\n     *\/\n    @Override\n    public boolean onCreateOptionsMenu(Menu menu) {\n        \/\/ \u30e1\u30cb\u30e5\u30fc\u3092\u5b9a\u7fa9\u3057\u305fXML\u3092\u8aad\u8fbc\u307f\u307e\u3059\u3002\n        getMenuInflater().inflate(R.menu.action_bar_sample, menu);\n\n        \/\/ SearchView\u306e\u4f5c\u6210\n        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);\n        SearchView searchView = (SearchView) menu.findItem(R.id.actionbar_search).getActionView();\n        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));\n\n        \/\/ \u30a4\u30d9\u30f3\u30c8\u30ea\u30b9\u30ca\u30fc\u51e6\u7406\n        SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {\n\n            \/\/ \u691c\u7d22\u7a93\u304b\u3089\u6587\u5b57\u304c\u5165\u529b\u3055\u308c\u308b\u5ea6\u306b\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002(\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u691c\u7d22)\n            @Override\n            public boolean onQueryTextChange(String searchWord) {\n\n                \/\/ \u3053\u3053\u306b\u691c\u7d22\u51e6\u7406\u3092\u8a18\u8f09\n\n                return true;\n            }\n\n            \/\/ \u691c\u7d22\u30dc\u30bf\u30f3\u3082\u3057\u304f\u306f\u3001\u30ad\u30fc\u30dc\u30fc\u30c9\u3067Enter\u3055\u308c\u305f\u969b\u306b\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002\n            @Override\n            public boolean onQueryTextSubmit(String searchWord) {\n                \/\/ \u4ed5\u69d8\u7684\u306b\u3001\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306a\u691c\u7d22\u3067\u306f\u3001\u5341\u5206\u3067\u306f\u306a\u3044\u3068\u5224\u65ad\u3059\u308b\u969b\u306f\u3001\u3053\u3053\u3044\u3082\u691c\u7d22\u51e6\u7406\u3092\u8a18\u8f09\n                return true;\n            }\n        };\n\n        \/\/ \u30a4\u30d9\u30f3\u30c8\u30ea\u30b9\u30ca\u30fc\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002\n        searchView.setOnQueryTextListener(queryTextListener);\n\n        return true;\n    }\n\n    \/**\n     \u30e1\u30cb\u30e5\u30fc\u306e\u30a2\u30a4\u30c6\u30e0\u304c\u9078\u629e\u3055\u308c\u305f\u969b\u306e\u51e6\u7406\u3067\u3059\u3002\n     *\/\n    @Override\n    public boolean onOptionsItemSelected(MenuItem item) {\n\n        int id = item.getItemId();\n\n        \/\/ \u65b0\u898f\u30dc\u30bf\u30f3\u8ffd\u52a0\u30dc\u30bf\u30f3\u304c\u30bf\u30c3\u30d7\u3055\u308c\u305f\u51e6\u7406\n        if (id == R.id.actionbar_add) {\n\n            \/\/ \u3053\u3053\u306b\u5177\u4f53\u7684\u306a\u51e6\u7406\u3092\u8a18\u8f09\n            \/\/ \u4f8b\u3048\u3070\u3001intent\u3067\u5225Activity\u306b\u9077\u79fb\u306a\u3069\n\n            \/\/ \u4ee5\u4e0b\u306f\u3001\u4eee\u306e\u51e6\u7406\n            Toast.makeText(this, \"The new button was pushed\", Toast.LENGTH_LONG);\n\n            return true;\n\n        }\n\n        return super.onOptionsItemSelected(item);\n    }\n}\n\n<\/pre>\n<p>\u30e1\u30cb\u30e5\u30fc\u306e\u8ffd\u52a0\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u300conCreateOptionsMenu\u300d\u306b\u306a\u308a\u3001<br \/> \u30e1\u30cb\u30e5\u30fc\u3092\u30bf\u30c3\u30d7\u3055\u308c\u305f\u5834\u5408\u306b\u52d5\u4f5c\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u300conOptionsItemSelected\u300d<br \/> \u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0a\u304c\u3001ActionBar\u30e1\u30cb\u30e5\u30fc\u4f5c\u6210\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3067\u3057\u305f\u3002<br \/> \u305d\u306e\u4ed6\u306b\u3082\u3001ActionBar\u306b\u306f\u3001\u30bf\u30d6\u306a\u3069\u3092\u8868\u793a\u3067\u304d\u308b\u6a5f\u80fd\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u304c\u3001<br \/> \u3053\u3061\u3089\u306f\u3001\u5f8c\u307b\u3069\u3001\u89e3\u8aac\u3057\u3066\u3044\u304f\u4e88\u5b9a\u3067\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u4eca\u56de\u3001\u89e3\u8aac\u3057\u305fActionBar\u306e\u30b5\u30f3\u30d7\u30eb\u306f\u3001\u4ee5\u4e0b\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\u3002<br \/>\n[wpdm_file id=3]\n","protected":false},"excerpt":{"rendered":"<p>ActionBar\u3068\u306f\uff1f \u30ed\u30b4\u3001\u30dc\u30bf\u30f3\u3001\u30bf\u30d6\u306a\u3069\u3092\u7c21\u5358\u306b\u5b9f\u73fe\u3067\u304d\u308b\u30c4\u30fc\u30eb\u30d0\u30fc\u3067\u3059\u3002 ActionBar\u306b\u30e1\u30cb\u30e5&#8230;<\/p>\n","protected":false},"author":1,"featured_media":244,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-56","post","type-post","status-publish","format-standard","has-post-thumbnail","category-android","article cf"],"_links":{"self":[{"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=\/wp\/v2\/posts\/56","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=56"}],"version-history":[{"count":2,"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":247,"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions\/247"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=\/wp\/v2\/media\/244"}],"wp:attachment":[{"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}