{"id":1058,"date":"2011-11-04T11:13:00","date_gmt":"2011-11-04T03:13:00","guid":{"rendered":"http:\/\/leybreeze.com\/blog\/?p=1058"},"modified":"2011-12-07T14:16:38","modified_gmt":"2011-12-07T06:16:38","slug":"%e5%8a%a8%e4%bd%9c%e6%9d%a1%ef%bc%88action-bar%ef%bc%89","status":"publish","type":"post","link":"http:\/\/leybreeze.com\/blog\/?p=1058","title":{"rendered":"\u52a8\u4f5c\u680f\uff08Action Bar\uff09"},"content":{"rendered":"<p>Action Bar\u662f\u6d3b\u52a8\u4e2d\u7684\u4e00\u79cd\u63a7\u4ef6\uff0c\u7528\u4ee5\u4ee3\u66ff\u4f20\u7edf\u7684\u5c4f\u5e55\u9876\u7aef\u7684\u6807\u9898\u680f\u3002\u9ed8\u8ba4\uff0cAction Bar\u5305\u62ec\u4e86\u5de6\u4fa7\u7684\u5e94\u7528\u7a0b\u5e8f\u56fe\u6807\uff08logo\uff09\uff0c\u5176\u53f3\u662f\u6d3b\u52a8\u7684\u6807\u9898\uff0c\u4ee5\u53caOption Menu\u4e2d\u7684\u53ef\u9009\u9879\u76ee\u3002Action Bar\u63d0\u4f9b\u4e86\u591a\u79cd\u4fbf\u5229\u7279\u6027\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u76f4\u63a5\u5728Action Bar\u4e2d\u663e\u793aOption Menu\u4e2d\u7684\u9879\u76ee\uff0c\u79f0\u4e4b\u4e3a\u201c\u52a8\u4f5c\u9879\u76ee\uff08action item\uff09\u201d\u2014\u2014\u4ee5\u63d0\u4f9b\u5bf9\u4e8e\u5173\u952e\u7528\u6237\u64cd\u4f5c\u7684\u5feb\u901f\u9009\u62e9\u3002\u6ca1\u6709\u4f5c\u4e3a\u52a8\u4f5c\u9879\u76ee\u663e\u793a\u7684\u83dc\u5355\u9879\u76ee\u5219\u4f4d\u5728\u6d6e\u52a8\u5f0f\u83dc\u5355\u4e2d\uff0c\u901a\u8fc7Action Bar\u7684\u4e0b\u62c9\u5217\u8868\u663e\u793a\u3002<\/li>\n<li>\u63d0\u4f9b\u5728\u4e0d\u540c\u7247\u6bb5\u4e4b\u95f4\u7684\u5bfc\u822a\u6807\u7b7e\u3002<\/li>\n<li>\u63d0\u4f9b\u5bfc\u822a\u7528\u7684\u4e0b\u62c9\u5217\u8868\u3002<\/li>\n<li>\u63d0\u4f9b\u4ea4\u4e92\u5f0f\u7684\u201c\u52a8\u4f5c\u89c6\u56fe\uff08action view\uff09\u201d\u4ee5\u4ee3\u66ff\u52a8\u4f5c\u9879\u76ee\uff08\u4f8b\u5982\u641c\u7d22\u6846\uff09\u3002<\/li>\n<\/ul>\n<figure id=\"attachment_1088\" aria-describedby=\"caption-attachment-1088\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/leybreeze.com\/blog\/?attachment_id=1088\" rel=\"attachment wp-att-1088\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1088\" title=\"actionbar\" src=\"http:\/\/leybreeze.com\/blog\/wp-content\/uploads\/2011\/11\/actionbar.png\" alt=\"\" width=\"500\" height=\"34\" \/><\/a><figcaption id=\"caption-attachment-1088\" class=\"wp-caption-text\">\u56fe1. Email\u5e94\u7528\u7a0b\u5e8f\u4e2dAction Bar\u7684\u4e00\u4e2a\u622a\u56fe\uff0c\u5305\u542b\u4e86\u7f16\u5199\u65b0\u90ae\u4ef6\u548c\u5237\u65b0\u6536\u4ef6\u7bb1\u7684\u52a8\u4f5c\u9879\u76ee\u3002<\/figcaption><\/figure>\n<h3><strong>\u6dfb\u52a0Action Bar<\/strong><\/h3>\n<p>Action Bar\u5728Android 3.0\u53ca\u4ee5\u4e0a\u7684\u6d3b\u52a8\u4e2d\u662f\u9ed8\u8ba4\u88ab\u5305\u542b\u7684\u3002\u66f4\u4e3a\u5177\u4f53\u5730\u8bf4\uff0c\u6240\u6709\u4f7f\u7528\u4e86\u65b0\u7684\u201cholographic\u201d\u4e3b\u9898\u7684\u6d3b\u52a8\u5c06\u5305\u542bAction Bar\uff0c\u800c\u4efb\u4f55\u4ee5Android 3.0\u4e3a\u76ee\u6807\u5e73\u53f0\u7684\u5e94\u7528\u7a0b\u5e8f\u5c06\u81ea\u52a8\u4f7f\u7528\u8be5\u4e3b\u9898\u3002\u5f53\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u5728&lt;uses-sdk&gt;\u5143\u7d20\u4e2d\u8bbe\u7f6e\u4e86<span style=\"color: #008000;\">android:minSdkVersion<\/span>\u6216<span style=\"color: #008000;\">android:targetSdkVersion<\/span>\u5c5e\u6027\u4e3a<span style=\"color: #008000;\">\u201c11\u201d<\/span>\u6216\u66f4\u9ad8\u65f6\uff0c\u88ab\u8ba4\u4e3a\u662f\u4ee5Android 3.0\u4e3a\u76ee\u6807\u5e73\u53f0\u7684\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><span style=\"color: #000000;\"><span style=\"color: #000080;\">&lt;manifest<\/span> <span style=\"color: #800080;\">xmlns:android=<\/span><span style=\"color: #008000;\">\"http:\/\/schemas.android.com\/apk\/res\/android\"<\/span><\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #800080;\">\u00a0 \u00a0 \u00a0 package=<\/span><span style=\"color: #008000;\">\"com.example.helloworld\"<\/span><\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #800080;\">\u00a0 \u00a0 \u00a0 android:versionCode=<\/span><span style=\"color: #008000;\">\"1\"<\/span><\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #800080;\">\u00a0 \u00a0 \u00a0 android:versionName=<\/span><span style=\"color: #008000;\">\"1.0\"<\/span><span style=\"color: #000080;\">&gt;<\/span><\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 &lt;uses-sdk<\/span> <span style=\"color: #800080;\">android:minSdkVersion=<\/span><span style=\"color: #008000;\">\"4\"<\/span><\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <strong><span style=\"color: #800080;\">android:targetSdkVersion=<\/span><span style=\"color: #008000;\">\"11\"<\/span><\/strong> <span style=\"color: #000080;\">\/&gt;<\/span><\/span>\r\n<span style=\"color: #000080;\">\u00a0 \u00a0 &lt;application ... &gt;<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 \u00a0 \u00a0 ...<\/span>\r\n<span style=\"color: #000080;\">\u00a0 \u00a0 &lt;\/application&gt;<\/span>\r\n<span style=\"color: #000080;\">&lt;\/manifest&gt;<\/span><\/pre>\n<p>\u5728\u672c\u8303\u4f8b\u4e2d\uff0c\u7a0b\u5e8f\u8bf7\u6c42\u4e86\u6700\u5c0fAPI\u7b49\u7ea7\u4e3a4\uff08Android 1.6\uff09\uff0c\u800c\u76ee\u6807API\u7b49\u7ea7\u4e3a11\uff08Android 3.0\uff09\u3002\u8fd9\u6837\uff0c\u5f53\u7a0b\u5e8f\u5b89\u88c5\u4e8e\u8fd0\u884cAndroid 3.0\u6216\u662f\u66f4\u9ad8\u7248\u672c\u7684\u8bbe\u5907\u4e0a\u65f6\uff0c\u7cfb\u7edf\u5c06\u4e3a\u6bcf\u4e00\u4e2a\u6d3b\u52a8\u63d0\u4f9bholographic\u4e3b\u9898\uff0c\u56e0\u800c\u6bcf\u4e2a\u6d3b\u52a8\u90fd\u5c06\u5305\u542bAction Bar\u3002<\/p>\n<p>\u4e0d\u8fc7\uff0c\u5982\u679c\u5e0c\u671b\u4f7f\u7528Action Bar\u7684API\uff0c\u4f8b\u5982\u6dfb\u52a0\u6807\u7b7e\u6216\u662f\u4fee\u6539Action Bar\u98ce\u683c\uff0c\u5c31\u9700\u8981\u5c06<span style=\"color: #008000;\">android:minSdkVersion<\/span>\u8bbe\u4e3a\u201c11\u201d\uff0c\u8fd9\u6837\u624d\u80fd\u4f7f\u7528ActionBar\u7c7b\u3002<\/p>\n<p><strong>\u79fb\u9664Action Bar<\/strong><\/p>\n<p>\u5982\u679c\u5e0c\u671b\u4ece\u67d0\u4e2a\u6307\u5b9a\u7684\u6d3b\u52a8\u4e2d\u79fb\u9664Action Bar\uff0c\u53ea\u9700\u5c06\u8be5\u6d3b\u52a8\u7684\u4e3b\u9898\u8bbe\u4e3aTheme.Holo.NoActionBar\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><span style=\"color: #000000;\"><span style=\"color: #000080;\">&lt;activity<\/span> <span style=\"color: #800080;\">android:theme<\/span>=<span style=\"color: #008000;\">\"@android:style\/Theme.Holo.NoActionBar\"<\/span><span style=\"color: #000080;\">&gt;<\/span><\/span><\/pre>\n<p style=\"padding-left: 30px;\"><strong>\u63d0\u793a\uff1a<\/strong>\u5982\u679c\u5e0c\u671b\u4ece\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684\u4e3b\u9898\u4e2d\u79fb\u9664Action Bar\uff0c\u53ea\u9700\u5c06android:windowActionBar\u6837\u5f0f\u5c5e\u6027\u8bbe\u4e3afalse\u3002\u5173\u4e8e\u66f4\u591aAction Bar\u6837\u5f0f\u7684\u5185\u5bb9\u8bf7\u53c2\u89c1\u201c\u5bf9Action Bar\u4f7f\u7528\u6837\u5f0f\u201d\u3002<\/p>\n<p>\u8fd8\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u901a\u8fc7\u8c03\u7528hide()\u6765\u9690\u85cfAction Bar\uff0c\u4e4b\u540e\u901a\u8fc7\u8c03\u7528show()\u6765\u518d\u6b21\u663e\u793a\u5b83\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><span style=\"color: #000000;\"><span style=\"color: #800080;\">ActionBar<\/span> actionBar = getActionBar();<\/span>\r\n<span style=\"color: #000000;\">actionBar.hide();<\/span><\/pre>\n<p>\u5f53Action Bar\u9690\u85cf\u65f6\uff0c\u7cfb\u7edf\u5c06\u8c03\u6574\u6d3b\u52a8\u7684\u5185\u5bb9\u6765\u586b\u5145\u53ef\u7528\u7684\u5c4f\u5e55\u7a7a\u95f4\u3002<\/p>\n<p style=\"padding-left: 30px;\"><strong>\u6ce8\u610f\uff1a<\/strong>\u5982\u679c\u79fb\u9664\u4e86\u4f7f\u7528\u4e3b\u9898\u7684Action Bar\uff0c\u90a3\u4e48\u8be5\u7a97\u53e3\u5c06\u5b8c\u5168\u7981\u7528Action Bar\u800c\u65e0\u6cd5\u518d\u5728\u8fd0\u884c\u65f6\u6dfb\u52a0\u2014\u2014\u8c03\u7528getActionBar()\u5c06\u8fd4\u56denull\u3002<\/p>\n<h3><strong>\u6dfb\u52a0\u52a8\u4f5c\u9879\u76ee<\/strong><\/h3>\n<p>\u52a8\u4f5c\u9879\u76ee\u4ec5\u4ec5\u662fOption Menu\u4e2d\u88ab\u58f0\u660e\u8981\u76f4\u63a5\u663e\u793a\u5728Action Bar\u4e0a\u7684\u83dc\u5355\u9879\u76ee\u3002\u4e00\u4e2a\u52a8\u4f5c\u9879\u76ee\u53ef\u4ee5\u5305\u62ec\u4e00\u4e2a\u56fe\u6807\u548c\/\u6216\u6587\u672c\u3002\u5982\u679c\u4e00\u4e2a\u83dc\u5355\u9879\u76ee\u4e0d\u662f\u52a8\u4f5c\u9879\u76ee\uff0c\u90a3\u4e48\u7cfb\u7edf\u5c06\u628a\u5b83\u653e\u5728\u6d6e\u52a8\u5f0f\u83dc\u5355\u4e2d\uff0c\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u9009\u62e9Action Bar\u53f3\u4fa7\u7684\u83dc\u5355\u56fe\u6807\u6253\u5f00\u6d6e\u52a8\u5f0f\u83dc\u5355\u3002<\/p>\n<p>\u5f53\u6d3b\u52a8\u542f\u52a8\u65f6\uff0c\u7cfb\u7edf\u5c06\u901a\u8fc7\u8c03\u7528onCreateOptionMenu()\u6765\u4e3a\u6d3b\u52a8\u751f\u6210Action Bar\u548c\u6d6e\u52a8\u5f0f\u83dc\u5355\u3002\u5982\u540c\u5728\u201c\u83dc\u5355\u201d\u5f00\u53d1\u8005\u6307\u5357\u4e2d\u6240\u63cf\u8ff0\u7684\uff0c\u8fd9\u662f\u4e3a\u6d3b\u52a8\u5b9a\u4e49Option Menu\u7684\u56de\u9988\u65b9\u6cd5\u3002<\/p>\n<p>\u53ef\u4ee5\u6307\u5b9a\u67d0\u4e00\u83dc\u5355\u9879\u76ee\u4f5c\u4e3a\u52a8\u4f5c\u9879\u76ee\u663e\u793a\u2014\u2014\u5982\u679c\u6709\u8fd9\u6837\u7684\u7a7a\u95f4\u7684\u8bdd\u2014\u2014\u901a\u8fc7\u5728\u83dc\u5355\u8d44\u6e90\u4e2d\u4e3a<span style=\"color: #008000;\">&lt;item&gt;<\/span>\u5143\u7d20\u58f0\u660e<span style=\"color: #008000;\">android:showAsAction=&#8221;ifRoom&#8221;<\/span>\u3002\u8fd9\u6837\uff0c\u8be5\u83dc\u5355\u9879\u76ee\u4ec5\u4f1a\u5728\u7a7a\u95f4\u8db3\u591f\u65f6\u663e\u793a\u5728Action Bar\u4e2d\u4ee5\u4f9b\u5feb\u901f\u9009\u62e9\u3002\u5982\u679c\u7a7a\u95f4\u4e0d\u8db3\uff0c\u8be5\u9879\u76ee\u5c06\u88ab\u7f6e\u4e8e\u6d6e\u52a8\u5f0f\u83dc\u5355\u4e2d\uff08\u901a\u8fc7Action Bar\u53f3\u4fa7\u7684\u83dc\u5355\u56fe\u6807\u6253\u5f00\uff09\u3002<\/p>\n<p>\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u4e2d\u58f0\u660e\u4e00\u4e2a\u83dc\u5355\u9879\u76ee\u4e3a\u52a8\u4f5c\u9879\u76ee\uff0c\u53ea\u9700\u5bf9MenuItem\u8c03\u7528setShowAsAction()\u5e76\u4f20\u9012SHOW_AS_ACTION_IF_ROOM\u3002<\/p>\n<p>\u5982\u679c\u83dc\u5355\u9879\u76ee\u540c\u65f6\u63d0\u4f9b\u4e86\u6807\u9898\u548c\u56fe\u6807\uff0c\u90a3\u4e48\u52a8\u4f5c\u9879\u76ee\u9ed8\u8ba4\u53ea\u663e\u793a\u56fe\u6807\u3002\u5982\u679c\u5e0c\u671b\u8ba9\u52a8\u4f5c\u9879\u76ee\u5305\u542b\u6587\u672c\uff0c\u9700\u8981\u5728XML\u4e2d\u6dfb\u52a0&#8221;with text&#8221;\u65d7\u6807\u3001\u5bf9<span style=\"color: #008000;\">android:showAsAction<\/span>\u5c5e\u6027\u6dfb\u52a0<span style=\"color: #008000;\">withText<\/span>\uff0c\u6216\u662f\u5728\u7a0b\u5e8f\u4ee3\u7801\u4e2d\u8c03\u7528setShowAsAction()\u5e76\u4f7f\u7528SHOW_AS_ACTION_WITH_TEXT\u65d7\u6807\u3002\u56fe2\u5c55\u793a\u4e86\u6709\u4e24\u4e2a\u5e26\u6709\u6587\u5b57\u7684\u52a8\u4f5c\u9879\u76ee\u4ee5\u53ca\u6d6e\u52a8\u5f0f\u83dc\u5355\u56fe\u6807\u7684Action Bar\u3002<\/p>\n<figure id=\"attachment_1110\" aria-describedby=\"caption-attachment-1110\" style=\"width: 355px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/leybreeze.com\/blog\/?attachment_id=1110\" rel=\"attachment wp-att-1110\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1110\" title=\"actionbar-item-withtext\" src=\"http:\/\/leybreeze.com\/blog\/wp-content\/uploads\/2011\/11\/actionbar-item-withtext.png\" alt=\"\" width=\"355\" height=\"57\" \/><\/a><figcaption id=\"caption-attachment-1110\" class=\"wp-caption-text\">\u56fe2. \u6709\u4e24\u4e2a\u52a8\u4f5c\u9879\u76ee\u4ee5\u53ca\u6d6e\u52a8\u5f0f\u83dc\u5355\u56fe\u6807\u7684Action Bar\u7684\u5c4f\u5e55\u622a\u56fe\u3002<\/figcaption><\/figure>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u5728\u83dc\u5355\u8d44\u6e90\u6587\u4ef6\u4e2d\u5c06\u83dc\u5355\u9879\u76ee\u58f0\u660e\u4e3a\u52a8\u4f5c\u9879\u76ee\u7684\u4e00\u4e2a\u8303\u4f8b\uff1a<\/p>\n<pre><span style=\"color: #000000;\">&lt;?xml version=<span style=\"color: #008000;\">\"1.0\"<\/span> encoding=<span style=\"color: #008000;\">\"utf-8\"<\/span>?&gt;<\/span>\r\n<span style=\"color: #800080;\"><span style=\"color: #000080;\">&lt;menu<\/span> xmlns:android=<span style=\"color: #008000;\">\"http:\/\/schemas.android.com\/apk\/res\/android\"<\/span>&gt;<\/span>\r\n<span style=\"color: #800080;\"><span style=\"color: #000080;\">\u00a0 \u00a0 &lt;item<\/span> android:id=<span style=\"color: #008000;\">\"@+id\/menu_save\"<\/span><\/span>\r\n<span style=\"color: #800080;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 android:icon=<span style=\"color: #008000;\">\"@drawable\/ic_menu_save\"<\/span><\/span>\r\n<span style=\"color: #800080;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 android:title=<span style=\"color: #008000;\">\"@string\/menu_save\"<\/span><\/span>\r\n\u00a0 \u00a0 <strong><span style=\"color: #800080;\">android:showAsAction<\/span><span style=\"color: #800080;\">=<\/span><\/strong><span style=\"color: #800080;\"><strong><span style=\"color: #008000;\">\"ifRoom|withText\"<\/span><\/strong> <span style=\"color: #000080;\">\/&gt;<\/span><\/span>\r\n<span style=\"color: #000080;\">&lt;\/menu&gt;<\/span><\/pre>\n<p>\u5728\u8fd9\u65f6\uff0c<span style=\"color: #008000;\">ifRoom<\/span>\u548c<span style=\"color: #008000;\">withText<\/span>\u65d7\u6807\u90fd\u88ab\u8bbe\u7f6e\u4e86\uff0c\u6240\u4ee5\u5f53\u8fd9\u4e2a\u9879\u76ee\u4f5c\u4e3a\u52a8\u4f5c\u9879\u76ee\u663e\u793a\u65f6\uff0c\u5b83\u5305\u542b\u4e86\u56fe\u6807\u4ee5\u53ca\u6807\u9898\u6587\u672c\u3002<\/p>\n<p>Action Bar\u4e2d\u7684\u83dc\u5355\u9879\u76ee\u548cOption Menu\u4e2d\u7684\u5176\u4ed6\u9879\u76ee\u90fd\u4f1a\u542f\u53d1\u76f8\u540c\u7684\u56de\u9988\u65b9\u6cd5\u3002\u5f53\u7528\u6237\u9009\u62e9\u4e86\u4e00\u4e2a\u52a8\u4f5c\u9879\u76ee\u65f6\uff0c\u6d3b\u52a8\u5c06\u6536\u5230\u4e00\u4e2aonOptionsItemSelected()\u7684\u8c03\u7528\uff0c\u5e76\u4f20\u9012\u9879\u76eeID\u3002<\/p>\n<p style=\"padding-left: 30px;\"><strong>\u6ce8\u610f\uff1a<\/strong>\u5982\u679c\u7528\u7247\u6bb5\u4e2d\u6dfb\u52a0\u83dc\u5355\u9879\u76ee\uff0c\u90a3\u4e48\u8be5\u7247\u6bb5\u76f8\u5e94\u7684onOptionsItemSelected()\u65b9\u6cd5\u5c06\u88ab\u8c03\u7528\u3002\u7136\u800c\u6d3b\u52a8\u53ef\u4ee5\u5728\u6b64\u4e4b\u524d\u5148\u5bf9\u5176\u8fdb\u884c\u5904\u7406\uff0c\u4e5f\u5c31\u662f\u8bf4\u7cfb\u7edf\u5bf9\u6d3b\u52a8\u7684onOptionsItemSelected()\u8c03\u7528\u8981\u5148\u4e8e\u5bf9\u7247\u6bb5\u7684\u3002<\/p>\n<p>\u53ef\u4ee5\u58f0\u660e\u4e00\u4e2a\u9879\u76ee\u603b\u662f\u4f5c\u4e3a\u52a8\u4f5c\u9879\u76ee\u51fa\u73b0\uff0c\u4e0d\u8fc7\u8fd9\u5e76\u4e0d\u88ab\u63a8\u8350\uff0c\u56e0\u4e3a\u8fd9\u4f1a\u5728\u6709\u592a\u591a\u7684\u52a8\u4f5c\u9879\u76ee\u65f6\u8ba9UI\u53d8\u5f97\u6df7\u4e71\uff0cAction Bar\u4e2d\u7684\u52a8\u4f5c\u9879\u76ee\u5c06\u4f1a\u9879\u76ee\u91cd\u53e0\u3002<\/p>\n<p>\u5173\u4e8e\u83dc\u5355\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u89c1\u201c<a title=\"\u521b\u5efa\u83dc\u5355\" href=\"http:\/\/leybreeze.com\/blog\/?p=313\">\u83dc\u5355<\/a>\u201d\u5f00\u53d1\u8005\u6307\u5357\u3002<\/p>\n<p><strong>\u5c06\u5e94\u7528\u56fe\u6807\u7528\u4f5c\u83dc\u5355\u9879\u76ee<\/strong><\/p>\n<p>\u5e94\u7528\u7a0b\u5e8f\u56fe\u6807\u9ed8\u8ba4\u51fa\u73b0\u5728Action Bar\u7684\u5de6\u4fa7\u3002\u5b83\u4e5f\u5c06\u54cd\u5e94\u7528\u6237\u4ea4\u4e92\u64cd\u4f5c\uff08\u5f53\u7528\u6237\u70b9\u51fb\u5b83\u65f6\uff0c\u5b83\u4f1a\u6709\u548c\u5176\u4ed6\u52a8\u4f5c\u9879\u76ee\u4e00\u6837\u7684\u89c6\u89c9\u54cd\u5e94\uff09\uff0c\u4f46\u9700\u8981\u624b\u52a8\u6307\u5b9a\u7528\u6237\u70b9\u51fb\u65f6\u7684\u884c\u4e3a\u3002<\/p>\n<figure id=\"attachment_1121\" aria-describedby=\"caption-attachment-1121\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/leybreeze.com\/blog\/?attachment_id=1121\" rel=\"attachment wp-att-1121\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1121\" title=\"actionbar\" src=\"http:\/\/leybreeze.com\/blog\/wp-content\/uploads\/2011\/11\/actionbar1.png\" alt=\"\" width=\"500\" height=\"34\" \/><\/a><figcaption id=\"caption-attachment-1121\" class=\"wp-caption-text\">\u56fe 3. Email\u7684Action Bar\uff0c\u5de6\u4fa7\u6709\u5e94\u7528\u7a0b\u5e8f\u56fe\u6807\u3002<\/figcaption><\/figure>\n<p>\u901a\u5e38\u7684\u884c\u4e3a\u5e94\u5f53\u662f\u5728\u7528\u6237\u5355\u51fb\u56fe\u6807\u65f6\u8ba9\u5e94\u7528\u7a0b\u5e8f\u56de\u5230\u201c\u4e3b\u6d3b\u52a8\u201d\u6216\u662f\uff08\u6bd4\u5982\uff0c\u5728\u6d3b\u52a8\u6ca1\u6709\u53d1\u751f\u53d8\u5316\u800c\u7247\u6bb5\u53d8\u5316\u4e86\u7684\u65f6\u5019\uff09\u56de\u5230\u521d\u59cb\u72b6\u6001\u3002\u5982\u679c\u7528\u6237\u5df2\u7ecf\u5904\u4e8e\u4e3b\u6d3b\u52a8\u6216\u662f\u521d\u59cb\u72b6\u6001\uff0c\u5219\u4e0d\u5fc5\u8fdb\u884c\u4efb\u4f55\u5904\u7406\u3002<\/p>\n<p>\u5f53\u7528\u6237\u5355\u51fb\u56fe\u6807\u65f6\uff0c\u7cfb\u7edf\u4ee5android.R.id.home\u7684ID\u8c03\u7528\u8be5\u6d3b\u52a8\u7684onOptionsItemSelected()\u65b9\u6cd5\u3002\u56e0\u6b64\uff0c\u9700\u8981\u5728onOptionsItemSelected()\u65b9\u6cd5\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u6761\u4ef6\u5224\u65ad\u6765\u4fa6\u542candroid.R.id.home\u5e76\u6267\u884c\u6b63\u786e\u7684\u884c\u4e3a\uff0c\u4f8b\u5982\u542f\u52a8\u4e3b\u6d3b\u52a8\u6216\u662f\u5c06\u6700\u8fd1\u7684\u7247\u6bb5\u4e8b\u52a1\u51fa\u6808\u3002<\/p>\n<p>\u5982\u679c\u901a\u8fc7\u8fd4\u56de\u4e3b\u6d3b\u52a8\u6765\u54cd\u5e94\u5e94\u7528\u56fe\u6807\u7684\u70b9\u51fb\uff0c\u90a3\u4e48\u9700\u8981\u5728Intent\u5185\u5305\u542bFLAG_ACTIVITY_CLEAR_TOP\u65d7\u6807\u3002\u8fd9\u6837\uff0c\u5982\u679c\u8981\u542f\u52a8\u7684\u6d3b\u52a8\u5df2\u7ecf\u5b58\u5728\u4e8e\u5f53\u524d\u4efb\u52a1\u7684\u8bdd\uff0c\u6240\u6709\u5728\u5176\u4e0a\u7684\u6d3b\u52a8\u5c06\u88ab\u9500\u6bc1\uff0c\u8be5\u6d3b\u52a8\u5c06\u56de\u5230\u6700\u4e0a\u5c42\u3002\u8fd9\u79cd\u65b9\u5f0f\u662f\u4ee4\u4eba\u6ee1\u610f\u7684\uff0c\u56e0\u4e3a\u56de\u5230\u201c\u4e3b\u6d3b\u52a8\u201d\u548c\u201c\u8fd4\u56de\u201d\u662f\u7b49\u4ef7\u7684\uff0c\u4e0d\u5e94\u8be5\u4e3a\u4e3b\u6d3b\u52a8\u521b\u5efa\u65b0\u7684\u5b9e\u4f8b\u3002\u5426\u5219\uff0c\u6700\u7ec8\u5728\u5f53\u524d\u4efb\u52a1\u4e2d\u4f1a\u6709\u4e00\u4e2a\u5f88\u957f\u7684\u6d3b\u52a8\u6808\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u4e0b\u9762\u662f\u4e00\u4e2aonOptionsItemSelected()\u7684\u5b9e\u73b0\uff0c\u5b83\u5c06\u8fd4\u56de\u5e94\u7528\u7a0b\u5e8f\u7684\u201c\u4e3b\u6d3b\u52a8\u201d\uff1a<\/p>\n<pre><span style=\"color: #008080;\">@Override<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">public boolean<\/span> onOptionsItemSelected(<span style=\"color: #800080;\">MenuItem<\/span> item) {<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 switch<\/span> (item.getItemId()) {<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 \u00a0 \u00a0 case<\/span> android.R.id.home:<\/span>\r\n<span style=\"color: #993300;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ app icon in Action Bar clicked; go home<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #800080;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Intent<\/span> intent = <span style=\"color: #000080;\">new<\/span> <span style=\"color: #800080;\">Intent<\/span>(<span style=\"color: #000080;\">this<\/span>, <span style=\"color: #800080;\">HomeActivity<\/span>.<span style=\"color: #000080;\">class<\/span>);<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 intent.addFlags(<span style=\"color: #800080;\">Intent<\/span>.FLAG_ACTIVITY_CLEAR_TOP);<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 startActivity(intent);<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 return true<\/span>;<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 \u00a0 \u00a0 default<\/span>:<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 return<\/span> super.onOptionsItemSelected(item);<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 }<\/span>\r\n<span style=\"color: #000000;\">}<\/span><\/pre>\n<p><strong>\u4f7f\u7528\u5e94\u7528\u56fe\u6807\u6765\u8fdb\u884c\u201d\u5411\u4e0a\u4e00\u7ea7\u201c\u5bfc\u822a<\/strong><\/p>\n<p>\u8fd8\u53ef\u4ee5\u4f7f\u7528\u5e94\u7528\u7a0b\u5e8f\u7684\u56fe\u6807\u6765\u4e3a\u7528\u6237\u63d0\u4f9b\u201c\u5411\u4e0a\u4e00\u7ea7\u201d\u7684\u5bfc\u822a\u3002\u8fd9\u5728\u7a0b\u5e8f\u4e2d\u7684\u6d3b\u52a8\u603b\u662f\u4ee5\u67d0\u79cd\u56fa\u5b9a\u7684\u987a\u5e8f\u51fa\u73b0\u5e76\u671f\u671b\u7528\u6237\u80fd\u65b9\u4fbf\u5730\u8fd4\u56de\u4e0a\u4e00\u7ea7\u6d3b\u52a8\u7684\u60c5\u51b5\u4e0b\u7279\u522b\u6709\u7528\uff08\u4e0d\u8fc7\u65e0\u6240\u8c13\u7528\u6237\u662f\u600e\u6837\u8fdb\u5165\u5f53\u524d\u7684\u6d3b\u52a8\u7684\uff09\u3002<\/p>\n<p>\u54cd\u5e94\u8fd9\u4e00\u4e8b\u4ef6\u7684\u65b9\u5f0f\u548c\u8fd4\u56de\u4e3b\u6d3b\u52a8\u7684\u65b9\u5f0f\u662f\u76f8\u540c\u7684\uff08\u548c\u4e0a\u6587\u6240\u8bf4\u7684\u7c7b\u4f3c\uff0c\u53ea\u4e0d\u8fc7\u73b0\u5728\u662f\u6839\u636e\u5f53\u524d\u7684\u6d3b\u52a8\u662f\u54ea\u4e00\u4e2a\u6765\u542f\u52a8\u53e6\u4e00\u4e2a\u4e0d\u540c\u7684\u6d3b\u52a8\uff09\u3002\u4e3a\u4e86\u544a\u8bc9\u7528\u6237\u8fd9\u65f6\u7684\u60c5\u51b5\u5c06\u6709\u6240\u4e0d\u540c\uff0c\u552f\u4e00\u9700\u8981\u505a\u7684\u5c31\u662f\u628aAction Bar\u8bbe\u4e3a\u201cshow home as up\u201d\u3002\u8fd9\u901a\u8fc7\u5bf9\u6d3b\u52a8\u7684ActionBar\u8c03\u7528setDisplayHomeAsUpEnabled(true)\u5373\u53ef\u5b8c\u6210\u3002\u8fd9\u65f6\uff0c\u7cfb\u7edf\u5c06\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7684\u56fe\u6807\u589e\u52a0\u4e00\u4e2a\u8868\u793a\u5411\u4e0a\u4e00\u5c42\u52a8\u4f5c\u7684\u7bad\u5934\uff0c\u5c31\u50cf\u56fe4\u8fd9\u6837\u3002<\/p>\n<figure id=\"attachment_1148\" aria-describedby=\"caption-attachment-1148\" style=\"width: 144px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/leybreeze.com\/blog\/?attachment_id=1148\" rel=\"attachment wp-att-1148\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1148\" title=\"actionbar-logo\" src=\"http:\/\/leybreeze.com\/blog\/wp-content\/uploads\/2011\/11\/actionbar-logo.png\" alt=\"\" width=\"144\" height=\"140\" \/><\/a><figcaption id=\"caption-attachment-1148\" class=\"wp-caption-text\">\u56fe 4. Email\u5e94\u7528\u7684\u6807\u51c6\u56fe\u6807\uff08\u4e0a\uff09\u548c\u201c\u5411\u4e0a\u4e00\u5c42\u201d\u56fe\u6807\uff08\u4e0b\uff09\u3002<\/figcaption><\/figure>\n<p>\u4f8b\u5982\uff0c\u4e0b\u9762\u662f\u5c06\u5e94\u7528\u56fe\u6807\u8868\u793a\u4e3a\u201c\u5411\u4e0a\u4e00\u5c42\u201d\u52a8\u4f5c\u7684\u65b9\u6cd5\uff1a<\/p>\n<pre><span style=\"color: #008080;\">@Override<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">protected void<\/span> onStart() {<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 super<\/span>.onStart();<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #800080;\">\u00a0 \u00a0 ActionBar<\/span> actionBar = <span style=\"color: #000080;\">this<\/span>.getActionBar();<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 actionBar.setDisplayHomeAsUpEnabled(<span style=\"color: #000080;\">true<\/span>);<\/span>\r\n<span style=\"color: #000000;\">}<\/span><\/pre>\n<p>\u4e4b\u540e\uff0c\u6d3b\u52a8\u5e94\u5f53\u5728\u7528\u6237\u5355\u51fb\u56fe\u6807\u65f6\u8fdb\u884c\u54cd\u5e94\uff0c\u5728onOptionsItemSelected()\u4e2d\uff0c\u901a\u8fc7\u76d1\u542cID <span style=\"color: #008000;\">android.R.id.home<\/span>\uff08\u5982\u4e0a\u6240\u793a\uff09\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5f53\u5411\u4e0a\u5bfc\u822a\u65f6\uff0c\u5728Intent\u4e2d\u4f7f\u7528FLAG_ACTIVITY_CLEAR_TOP\u65d7\u6807\u662f\u66f4\u4e3a\u91cd\u8981\u7684\uff0c\u8fd9\u6837\u624d\u80fd\u4e0d\u5728\u4e0a\u7ea7\u6d3b\u52a8\u7684\u5b9e\u4f8b\u5df2\u7ecf\u5b58\u5728\u65f6\u8fd8\u518d\u6b21\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u3002<\/p>\n<h3><strong>\u6dfb\u52a0\u4e00\u4e2a\u52a8\u4f5c\u89c6\u56fe\uff08Action View\uff09<\/strong><\/h3>\n<p>\u52a8\u4f5c\u89c6\u56fe\u662f\u5728Action Bar\u4e0a\u51fa\u73b0\u7684\u4e00\u4e2a\u63a7\u4ef6\uff0c\u4f5c\u4e3a\u52a8\u4f5c\u9879\u76ee\u7684\u4e00\u79cd\u66ff\u4ee3\u3002\u4f8b\u5982\uff0c\u5982\u679c\u5728Option Menu\u4e2d\u6709\u4e00\u4e2a\u9879\u76ee\u662f\u201c\u641c\u7d22\u201d\uff0c\u90a3\u4e48\u5f53\u8be5\u9879\u76ee\u4f5c\u4e3a\u52a8\u4f5c\u9879\u76ee\u4f7f\u7528\u65f6\u53ef\u4ee5\u5728Action Bar\u4e2d\u4e3a\u8be5\u9879\u76ee\u6dfb\u52a0\u4e00\u4e2a\u63d0\u4f9bSearchView\u63a7\u4ef6\u7684\u9879\u76ee\u3002<\/p>\n<p>\u5f53\u4e3a\u4e00\u4e2a\u83dc\u5355\u9879\u76ee\u6dfb\u52a0\u52a8\u4f5c\u89c6\u56fe\u65f6\uff0c\u5141\u8bb8\u8be5\u9879\u76ee\u5728\u6ca1\u6709\u51fa\u73b0\u4e8eAction Bar\u65f6\u4ecd\u80fd\u4f5c\u4e3a\u4e00\u4e2a\u901a\u5e38\u7684\u83dc\u5355\u9879\u76ee\u6267\u884c\u6307\u4ee4\u662f\u5f88\u91cd\u8981\u7684\u3002\u4f8b\u5982\uff0c\u4e00\u4e2a\u6267\u884c\u641c\u7d22\u5de5\u4f5c\u7684\u83dc\u5355\u9879\u76ee\u5e94\u8be5\u9ed8\u8ba4\u5f39\u51faAndroid\u641c\u7d22\u5bf9\u8bdd\u6846\uff0c\u4f46\u5982\u679c\u8be5\u9879\u76ee\u88ab\u7f6e\u4e8eAction Bar\u7684\u8bdd\uff0c\u52a8\u4f5c\u89c6\u56fe\u5c06\u4ee5SearchView\u63a7\u4ef6\u7684\u5f62\u5f0f\u663e\u793a\u3002\u56fe4\u5c55\u793a\u4e86\u4e00\u4e2a\u52a8\u4f5c\u89c6\u56fe\u7684SearchView\u63a7\u4ef6\u7684\u8303\u4f8b\u3002<\/p>\n<figure id=\"attachment_1153\" aria-describedby=\"caption-attachment-1153\" style=\"width: 429px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/leybreeze.com\/blog\/?attachment_id=1153\" rel=\"attachment wp-att-1153\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1153\" title=\"actionbar-actionview\" src=\"http:\/\/leybreeze.com\/blog\/wp-content\/uploads\/2011\/11\/actionbar-actionview.png\" alt=\"\" width=\"429\" height=\"55\" \/><\/a><figcaption id=\"caption-attachment-1153\" class=\"wp-caption-text\">\u56fe4. \u5e26\u6709\u4e00\u4e2aSearchView\u63a7\u4ef6\u7684\u52a8\u4f5c\u89c6\u56fe\u3002<\/figcaption><\/figure>\n<p>\u4e3a\u4e00\u4e2a\u9879\u76ee\u58f0\u660e\u52a8\u4f5c\u89c6\u56fe\u6700\u597d\u7684\u65b9\u5f0f\u662f\u5728\u83dc\u5355\u8d44\u6e90\u4e2d\u4f7f\u7528<span style=\"color: #008000;\">android:actionLayout<\/span>\u6216\u662f<span style=\"color: #008000;\">android:actionViewClass<\/span>\u5c5e\u6027\uff1a<\/p>\n<ul>\n<li><span style=\"color: #008000;\">android:actionLayout<\/span>\u7684\u503c\u5fc5\u987b\u662f\u6307\u5411\u4e00\u4e2a\u5e03\u5c40\u6587\u4ef6\u7684\u8d44\u6e90\u6307\u9488\u3002\u4f8b\u5982\uff1a<\/li>\n<\/ul>\n<pre><span style=\"color: #000000;\">&lt;?xml version=<span style=\"color: #008000;\">\"1.0\"<\/span> encoding=<span style=\"color: #008000;\">\"utf-8\"<\/span>?&gt;<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">&lt;menu<\/span> <span style=\"color: #800080;\">xmlns:android<\/span>=<span style=\"color: #008000;\">\"http:\/\/schemas.android.com\/apk\/res\/android\"<\/span><span style=\"color: #000080;\">&gt;<\/span><\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 &lt;item<\/span> <span style=\"color: #800080;\">android:id<\/span>=<span style=\"color: #008000;\">\"@+id\/menu_search\"<\/span><\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #800080;\">\u00a0 \u00a0 \u00a0 \u00a0 android:title<\/span>=<span style=\"color: #008000;\">\"Search\"<\/span><\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #800080;\">\u00a0 \u00a0 \u00a0 \u00a0 android:icon<\/span>=<span style=\"color: #008000;\">\"@drawable\/ic_menu_search\"<\/span><\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #800080;\">\u00a0 \u00a0 \u00a0 \u00a0 android:showAsAction<\/span>=<span style=\"color: #008000;\">\"ifRoom\"<\/span><\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 \u00a0 \u00a0 <strong><span style=\"color: #800080;\">android:actionLayout<\/span>=<span style=\"color: #008000;\">\"@layout\/searchview\"<\/span><\/strong> <span style=\"color: #000080;\">\/&gt;<\/span><\/span>\r\n<span style=\"color: #000080;\">&lt;\/menu&gt;<\/span><\/pre>\n<ul>\n<li><span style=\"color: #008000;\">android:actionViewClass<\/span>\u7684\u503c\u5fc5\u987b\u662f\u4e00\u4e2a\u6240\u8981\u4f7f\u7528\u7684View\u7684\u5b8c\u6574\u7c7b\u540d\u3002\u4f8b\u5982\uff1a<\/li>\n<\/ul>\n<pre><span style=\"color: #000000;\">&lt;?xml version=<span style=\"color: #008000;\">\"1.0\"<\/span> encoding=<span style=\"color: #008000;\">\"utf-8\"<\/span>?&gt;<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">&lt;menu<\/span> <span style=\"color: #800080;\">xmlns:android<\/span>=<span style=\"color: #008000;\">\"http:\/\/schemas.android.com\/apk\/res\/android\"<\/span><span style=\"color: #000080;\">&gt;<\/span><\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 &lt;item<\/span> <span style=\"color: #800080;\">android:id<\/span>=<span style=\"color: #008000;\">\"@+id\/menu_search\"<\/span><\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #800080;\">\u00a0 \u00a0 \u00a0 \u00a0 android:title<\/span>=<span style=\"color: #008000;\">\"Search\"<\/span><\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #800080;\">\u00a0 \u00a0 \u00a0 \u00a0 android:icon<\/span>=<span style=\"color: #008000;\">\"@drawable\/ic_menu_search\"<\/span><\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #800080;\">\u00a0 \u00a0 \u00a0 \u00a0 android:showAsAction<\/span>=<span style=\"color: #008000;\">\"ifRoom\"<\/span><\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 \u00a0 \u00a0 <strong><span style=\"color: #800080;\">android:actionViewClass<\/span>=<span style=\"color: #008000;\">\"android.widget.SearchView\"<\/span><\/strong> <span style=\"color: #000080;\">\/&gt;<\/span><\/span>\r\n<span style=\"color: #000080;\">&lt;\/menu&gt;<\/span><\/pre>\n<p>\u5fc5\u987b\u5305\u542b<span style=\"color: #008000;\">android:showAsAction=&#8221;ifRoom&#8221;<\/span>\u4ee5\u4f7f\u9879\u76ee\u5728\u7a7a\u95f4\u8db3\u591f\u65f6\u4f5c\u4e3a\u52a8\u4f5c\u89c6\u56fe\u663e\u793a\u3002\u4e0d\u8fc7\uff0c\u5728\u5fc5\u8981\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e<span style=\"color: #008000;\">android:showAsAction<\/span>\u4e3a<span style=\"color: #008000;\">&#8220;always&#8221;<\/span>\u6765\u5f3a\u5236\u8be5\u9879\u76ee\u4ee5\u52a8\u4f5c\u89c6\u56fe\u663e\u793a\u3002<\/p>\n<p>\u73b0\u5728\uff0c\u5f53\u83dc\u5355\u9879\u76ee\u4f5c\u4e3a\u4e00\u4e2a\u52a8\u4f5c\u9879\u76ee\u663e\u793a\u65f6\uff0c\u5b83\u5c06\u662f\u4e00\u4e2a\u52a8\u4f5c\u89c6\u56fe\u800c\u4e0d\u662f\u56fe\u6807\u548c\/\u6216\u6807\u9898\u6587\u672c\u3002\u4e0d\u8fc7\uff0c\u5982\u679c\u5728Action Bar\u4e2d\u6ca1\u6709\u8db3\u591f\u7684\u7a7a\u95f4\u7684\u8bdd\uff0c\u8be5\u9879\u76ee\u5c06\u5728\u6d6e\u52a8\u5f0f\u83dc\u5355\u4e2d\u4ee5\u4e00\u4e2a\u901a\u5e38\u83dc\u5355\u9879\u76ee\u7684\u5f62\u5f0f\u663e\u793a\uff0c\u5fc5\u987b\u5728onOptionsItemSelected()\u56de\u9988\u65b9\u6cd5\u4e2d\u54cd\u5e94\u8be5\u9879\u76ee\u3002<\/p>\n<p>\u5f53\u6d3b\u52a8\u9996\u6b21\u542f\u52a8\u65f6\uff0c\u7cfb\u7edf\u901a\u8fc7\u8c03\u7528onCreateOptionsMenu()\u751f\u6210Action Bar\u548c\u6d6e\u52a8\u5f0f\u83dc\u5355\u3002\u5f53\u83dc\u5355\u5728\u8be5\u65b9\u6cd5\u4e2d\u88ab\u5c55\u5f00\u4e4b\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u83dc\u5355\u9879\u76ee\u7684ID\u8c03\u7528findItem()\u6765\u83b7\u53d6\u52a8\u4f5c\u89c6\u56fe\u7684\u5143\u7d20\uff08\u6bd4\u5982\u4e3a\u4e86\u7ed1\u5b9a\u76d1\u542c\u5668\uff09\uff0c\u800c\u540e\u5bf9\u6240\u8fd4\u56de\u7684MenuItem\u8c03\u7528getActionView()\u3002\u4f8b\u5982\uff0c\u4e0a\u9762\u7684\u4f8b\u5b50\u91cc\u7684\u641c\u7d22\u63a7\u4ef6\u53ef\u4ee5\u50cf\u8fd9\u6837\u83b7\u5f97\uff1a<\/p>\n<pre><span style=\"color: #008080;\">@Override<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">public boolean<\/span> onCreateOptionsMenu(<span style=\"color: #800080;\">Menu<\/span> menu) {<\/span>\r\n<span style=\"color: #000000;\">\u00a0 getMenuInflater().inflate(R.menu.options, menu);<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #800080;\">\u00a0 SearchView<\/span> searchView = (<span style=\"color: #800080;\">SearchView<\/span>) menu.findItem(R.id.menu_search).getActionView();<\/span>\r\n<span style=\"color: #993300;\">\u00a0 \/\/ Set appropriate listeners for searchView<\/span>\r\n<span style=\"color: #993300;\">\u00a0 ...<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 return super<\/span>.onCreateOptionsMenu(menu);<\/span>\r\n<span style=\"color: #000000;\">}<\/span><\/pre>\n<p>\u5173\u4e8e\u4f7f\u7528\u641c\u7d22\u63a7\u4ef6\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u89c1\u201c\u521b\u5efa\u4e00\u4e2a\u641c\u7d22\u63a5\u53e3\u201d\u3002<\/p>\n<h3><strong>\u00a0\u6dfb\u52a0\u6807\u7b7e\uff08tab\uff09<\/strong><\/h3>\n<p>\u52a8\u4f5c\u680f\u53ef\u4ee5\u663e\u793a\u6807\u7b7e\u4ee5\u4f7f\u7528\u6237\u5728\u6d3b\u52a8\u5185\u7684\u4e0d\u540c\u7247\u6bb5\u4e4b\u95f4\u5bfc\u822a\u3002\u6bcf\u4e00\u4e2a\u6807\u7b7e\u53ef\u4ee5\u5305\u542b\u4e00\u4e2a\u6807\u9898\u548c\/\u6216\u4e00\u4e2a\u56fe\u6807\u3002<\/p>\n<figure id=\"attachment_1158\" aria-describedby=\"caption-attachment-1158\" style=\"width: 504px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/leybreeze.com\/blog\/?attachment_id=1158\" rel=\"attachment wp-att-1158\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1158\" title=\"actionbar-tabs\" src=\"http:\/\/leybreeze.com\/blog\/wp-content\/uploads\/2011\/11\/actionbar-tabs.png\" alt=\"\" width=\"504\" height=\"58\" \/><\/a><figcaption id=\"caption-attachment-1158\" class=\"wp-caption-text\">\u56fe 6. \u5728Honeycomb\u7248\u672c\u7684\u56fe\u5e93\u8303\u4f8b\u7a0b\u5e8f\u4e2d\u7684Action Bar\u4e2d\u7684\u6807\u7b7e\u7684\u622a\u56fe\u3002<\/figcaption><\/figure>\n<p>\u9996\u5148\uff0c\u5e03\u5c40\u5fc5\u987b\u5728\u6bcf\u4e00\u4e2a\u548c\u663e\u793a\u7684\u8868\u73b0\u76f8\u5173\u8054\u7684Fragment\u4e2d\u5305\u542b\u4e00\u4e2aView\u3002\u8981\u786e\u4fdd\u8be5\u89c6\u56fe\u6709\u4e00\u4e2a\u80fd\u5728\u4ee3\u7801\u4e2d\u5f15\u7528\u7684ID\u3002<\/p>\n<p>\u8981\u6dfb\u52a0\u6807\u7b7e\u81f3Action Bar\uff1a<\/p>\n<p>1. \u521b\u5efa\u4e00\u4e2aActionBar.TabListener\u7684\u5b9e\u73b0\u6765\u5904\u7406Action Bar\u6807\u7b7e\u7684\u4ea4\u4e92\u4e8b\u4ef6\u3002\u6bd4\u5982\u5b9e\u73b0\u6240\u6709\u7684\u65b9\u6cd5\uff1aonTabSelected()\u3001onTabUnselected()\u548conTabReselected()\u3002<\/p>\n<p>\u6bcf\u4e00\u4e2a\u56de\u9988\u65b9\u6cd5\u90fd\u5c06\u4f20\u9012\u6536\u5230\u4e86\u4e8b\u4ef6\u7684ActionBar.Tab\u548c\u4e00\u4e2aFragmentTransaction\u7528\u4ee5\u6267\u884c\u7247\u6bb5\u4e8b\u52a1\uff08\u6dfb\u52a0\u6216\u662f\u79fb\u9664\u7247\u6bb5\uff09\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre><span style=\"color: #000000;\"><span style=\"color: #000080;\">private class<\/span> <span style=\"color: #800080;\">MyTabListener<\/span> <span style=\"color: #000080;\">implements<\/span> <span style=\"color: #800080;\">ActionBar.TabListener<\/span> {<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 private<\/span> TabContentFragment mFragment;<\/span>\r\n\r\n<span style=\"color: #993300;\">\u00a0 \u00a0 \/\/ Called to create an instance of the listener when adding a new tab<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 public<\/span> <span style=\"color: #800080;\">MyTabListener<\/span>(<span style=\"color: #800080;\">TabContentFragment<\/span> fragment) {<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 \u00a0 \u00a0 mFragment = fragment;<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 }<\/span>\r\n\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 public<\/span> void onTabSelected(<span style=\"color: #800080;\">Tab<\/span> tab, <span style=\"color: #800080;\">FragmentTransaction<\/span> ft) {<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 \u00a0 \u00a0 ft.add(R.id.fragment_content, mFragment, <span style=\"color: #000080;\">null<\/span>);<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 }<\/span>\r\n\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 public<\/span> void onTabUnselected(<span style=\"color: #800080;\">Tab<\/span> tab, <span style=\"color: #800080;\">FragmentTransaction<\/span> ft) {<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 \u00a0 \u00a0 ft.remove(mFragment);<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 }<\/span>\r\n\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 public<\/span> void onTabReselected(<span style=\"color: #800080;\">Tab<\/span> tab, <span style=\"color: #800080;\">FragmentTransaction<\/span> ft) {<\/span>\r\n<span style=\"color: #993300;\">\u00a0 \u00a0 \u00a0 \u00a0 \/\/ do nothing<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 }<\/span>\r\n\r\n<span style=\"color: #000000;\">}<\/span><\/pre>\n<p>\u8fd9\u79cdActionBar.TabListener\u7684\u5b9e\u73b0\u6dfb\u52a0\u4e86\u4e00\u4e2a\u4fdd\u5b58\u4e0e\u6807\u7b7e\u5173\u8054\u7684Fragment\u7684\u6784\u9020\u51fd\u6570\u4ee5\u4f7f\u6bcf\u4e00\u4e2a\u56de\u9988\u51fd\u6570\u53ef\u4ee5\u6dfb\u52a0\u6216\u662f\u79fb\u9664\u7247\u6bb5\u3002<\/p>\n<p>2. \u5728onCreate()\u65f6\u901a\u8fc7\u5728Activity\u4e2d\u8c03\u7528getActionBar()\u6765\u83b7\u53d6\u6d3b\u52a8\u7684ActionBar\uff08\u4e0d\u8fc7\u8981\u6ce8\u610f\u9700\u8981\u5728\u8c03\u7528\u4e86setContentView()\u4e4b\u540e\u624d\u8fd9\u4e48\u505a\uff09\u3002<\/p>\n<p>3. \u8c03\u7528setNavigationMode(NAVIGATION_MODE_TABS)\u6765\u5f00\u542fActionBar\u7684\u6807\u7b7e\u6a21\u5f0f\u3002<\/p>\n<p>4. \u4e3aAction Bar\u521b\u5efa\u6240\u6709\u7684\u6807\u7b7e\uff1a<\/p>\n<p style=\"padding-left: 30px;\">1. \u901a\u8fc7\u5bf9ActionBar\u8c03\u7528newTab()\u6765\u521b\u5efa\u65b0\u7684ActionBar.Tab\u3002<\/p>\n<p style=\"padding-left: 30px;\">2. \u901a\u8fc7\u8c03\u7528setText()\u548c\/\u6216setIcon()\u6765\u4e3a\u6807\u7b7e\u6dfb\u52a0\u6587\u5b57\u548c\/\u6216\u56fe\u6807\u3002<\/p>\n<p style=\"padding-left: 30px;\"><strong>\u63d0\u793a\uff1a<\/strong>\u8fd9\u4e9b\u65b9\u6cd5\u8fd4\u56de\u76f8\u540c\u7684ActionBar.Tab\u5b9e\u4f8b\uff0c\u6240\u4ee5\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u8c03\u7528\u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n<p style=\"padding-left: 30px;\">3. \u58f0\u660eActionBar.TabListener\uff0c\u5e76\u901a\u8fc7\u5411setTabListener()\u4f20\u9012\u5176\u5b9e\u73b0\u7684\u4e00\u4e2a\u5b9e\u4f8b\u6765\u4f7f\u7528\u5b83\u3002<\/p>\n<p>5. \u901a\u8fc7\u5bf9ActionBar\u8c03\u7528addTab()\u6765\u6dfb\u52a0\u6240\u6709\u7684ActionBar.Tab\uff0c\u5e76\u4f20\u9012\u5b83\u4eec\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u4ee3\u7801\u7ed3\u5408\u4e86\u6b65\u9aa42-5\u6765\u521b\u5efa\u4e86\u4e24\u4e2a\u6807\u7b7e\u5e76\u5c06\u5b83\u4eec\u6dfb\u52a0\u81f3\u4e86Action Bar\uff1a<\/p>\n<pre><span style=\"color: #008080;\">@Override<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">protected void<\/span> onCreate(<span style=\"color: #800080;\">Bundle<\/span> savedInstanceState) {<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 super<\/span>.onCreate(savedInstanceState);<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 setContentView(R.layout.main);<\/span>\r\n\r\n<span style=\"color: #993300;\">\u00a0 \u00a0 \/\/ setup Action Bar for tabs<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #000080;\">\u00a0 \u00a0 final<\/span> <span style=\"color: #800080;\">ActionBar<\/span> actionBar = getActionBar();<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 actionBar.setNavigationMode(<span style=\"color: #800080;\">ActionBar<\/span>.NAVIGATION_MODE_TABS);<\/span>\r\n<span style=\"color: #993300;\">\u00a0 \u00a0 \/\/ remove the activity title to make space for tabs<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 actionBar.setDisplayShowTitleEnabled(<span style=\"color: #000080;\">false<\/span>);<\/span>\r\n\r\n<span style=\"color: #993300;\">\u00a0 \u00a0 \/\/ instantiate fragment for the tab<\/span>\r\n<span style=\"color: #000000;\"><span style=\"color: #800080;\">\u00a0 \u00a0 Fragment<\/span> artistsFragment = <span style=\"color: #000080;\">new<\/span> <span style=\"color: #800080;\">ArtistsFragment<\/span>();<\/span>\r\n<span style=\"color: #993300;\">\u00a0 \u00a0 \/\/ add a new tab and set its title text and tab listener<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 actionBar.addTab(actionBar.newTab().setText(R.<span style=\"color: #000080;\">string<\/span>.tab_artists)<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 .setTabListener(<span style=\"color: #000080;\">new<\/span> <span style=\"color: #800080;\">TabListener<\/span>(artistsFragment)));<\/span>\r\n\r\n<span style=\"color: #000000;\"><span style=\"color: #800080;\">\u00a0 \u00a0 Fragment<\/span> albumsFragment = <span style=\"color: #000080;\">new<\/span> <span style=\"color: #800080;\">AlbumsFragment<\/span>();<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 actionBar.addTab(actionBar.newTab().setText(R.<span style=\"color: #000080;\">string<\/span>.tab_albums)<\/span>\r\n<span style=\"color: #000000;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 .setTabListener(<span style=\"color: #000080;\">new<\/span> <span style=\"color: #800080;\">TabListener<\/span>(albumsFragment)));<\/span>\r\n<span style=\"color: #000000;\">}<\/span><\/pre>\n<p>\u6807\u7b7e\u88ab\u9009\u4e2d\u65f6\u6240\u6709\u9700\u8981\u8fdb\u884c\u7684\u884c\u4e3a\u90fd\u5fc5\u987b\u5728ActionBar.TabListener\u56de\u9988\u65b9\u6cd5\u4e2d\u88ab\u5b9a\u4e49\u3002\u5f53\u4e00\u4e2a\u6807\u7b7e\u88ab\u9009\u4e2d\uff0c\u5b83\u5c06\u6536\u5230\u4e00\u4e2aonTabSelected()\u7684\u8c03\u7528\uff0c\u5e94\u5f53\u5728\u8fd9\u91cc\u901a\u8fc7\u4f7f\u7528add()\u53ca\u6240\u63d0\u4f9b\u7684FragmentTransaction\u6765\u5411\u5e03\u5c40\u4e2d\u6307\u5b9a\u7684\u89c6\u56fe\u6dfb\u52a0\u6b63\u786e\u7684\u7247\u6bb5\u3002\u7c7b\u4f3c\u7684\uff0c\u5f53\u4e00\u4e2a\u6807\u7b7e\u88ab\u53d6\u6d88\u9009\u4e2d\u65f6\uff08\u56e0\u4e3a\u53e6\u4e00\u4e2a\u6807\u7b7e\u88ab\u9009\u4e2d\u4e86\uff09\uff0c\u5219\u5e94\u5f53\u4f7f\u7528remove()\u6765\u4ece\u5e03\u5c40\u4e2d\u79fb\u9664\u8be5\u7247\u6bb5\u3002<\/p>\n<p style=\"padding-left: 30px;\"><strong>\u6ce8\u610f\uff1a\u4e0d\u80fd<\/strong>\u4e3a\u8fd9\u4e9b\u4e8b\u52a1\u8c03\u7528commit()\u2014\u2014\u7cfb\u7edf\u4f1a\u8c03\u7528\u5b83\uff0c\u5982\u679c\u624b\u52a8\u8c03\u7528\u7684\u8bdd\u5c06\u4f1a\u629b\u51fa\u4e00\u4e2a\u4f8b\u5916\u3002\u540c\u65f6\u4e5f<strong>\u4e0d\u80fd<\/strong>\u5c06\u8fd9\u4e9b\u7247\u6bb5\u4e8b\u52a1\u6dfb\u52a0\u81f3\u8fd4\u56de\u6808\u3002<\/p>\n<p>\u5982\u679c\u6d3b\u52a8\u88ab\u4e2d\u6b62\uff0c\u5e94\u5f53\u4fdd\u5b58\u5f53\u524d\u9009\u4e2d\u7684\u6807\u7b7e\uff0c\u8fd9\u6837\u5f53\u7528\u6237\u8fd4\u56de\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u53ef\u4ee5\u6253\u5f00\u8be5\u4fdd\u5b58\u7684\u6807\u7b7e\u3002\u5728\u4fdd\u5b58\u72b6\u6001\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7getSelectedNavigationIndex()\u83b7\u53d6\u5f53\u524d\u9009\u4e2d\u7684\u6807\u7b7e\u3002\u8fd9\u5c06\u8fd4\u56de\u6240\u9009\u6807\u7b7e\u7684\u7d22\u5f15\u4f4d\u7f6e\u3002<\/p>\n<p style=\"padding-left: 30px;\"><strong>\u6ce8\u610f\uff1a<\/strong>\u5e94\u8be5\u5728\u5fc5\u8981\u65f6\u4fdd\u5b58\u6bcf\u4e00\u4e2a\u7247\u6bb5\u7684\u72b6\u6001\uff0c\u8fd9\u6837\u7528\u6237\u5728\u5207\u6362\u6807\u7b7e\u5e76\u8fd4\u56de\u524d\u4e00\u4e2a\u7247\u6bb5\u65f6\u80fd\u4fdd\u6301\u4e4b\u524d\u7684\u6837\u5b50\u3002\u5173\u4e8e\u4fdd\u5b58\u7247\u6bb5\u72b6\u6001\u7684\u66f4\u8fc7\u4fe1\u606f\uff0c\u8bf7\u53c2\u89c1\u201c\u7247\u6bb5\u201d\u5f00\u53d1\u8005\u6307\u5357\u3002<\/p>\n<h3><strong>\u6dfb\u52a0\u4e0b\u62c9\u5f0f\u5bfc\u822a<\/strong><\/h3>\n<p>&nbsp;<\/p>\n<p><em><span style=\"color: #888888;\">\u7531\u4e8e\u5b98\u65b9\u5bf9\u6587\u6863\u8fdb\u884c\u4e86\u66f4\u65b0\uff0c\u6709\u8f83\u5927\u7684\u6539\u52a8\u3002\u56e0\u6b64\u5bf9\u4e8e\u672c\u6587\u7684\u7ffb\u8bd1\u6682\u65f6\u4e2d\u6b62\uff0c\u5c06\u5728\u4e4b\u540e\u8fdb\u884c\u91cd\u65b0\u7ffb\u8bd1\u3002<\/span><\/em><\/p>\n<p>\u672c\u9875\u90e8\u5206\u5185\u5bb9\u6839\u636e<a title=\"Android Open Source Projec\" href=\"http:\/\/code.google.com\/intl\/zh-CN\/policies.html\" target=\"_blank\">Android Open Source Project<\/a>\u521b\u4f5c\u5e76\u5171\u4eab\u7684\u5185\u5bb9\u4fee\u6539\uff0c\u5e76\u5728<a title=\"\u77e5\u8bc6\u5171\u4eab \u7f72\u540d2.5\u8bb8\u53ef\u534f\u8bae\" href=\"http:\/\/creativecommons.org\/licenses\/by\/2.5\/\" target=\"_blank\">\u77e5\u8bc6\u5171\u4eab \u7f72\u540d2.5\u8bb8\u53ef\u534f\u8bae<\/a>\u4e2d\u6240\u8ff0\u6761\u6b3e\u7684\u9650\u5236\u4e0b\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Action Bar\u662f\u6d3b\u52a8\u4e2d\u7684\u4e00\u79cd\u63a7\u4ef6\uff0c\u7528\u4ee5\u4ee3\u66ff\u4f20\u7edf\u7684\u5c4f\u5e55\u9876\u7aef\u7684\u6807\u9898\u680f\u3002\u9ed8\u8ba4\uff0cAction Bar\u5305\u62ec\u4e86\u5de6\u4fa7\u7684 &hellip; <a href=\"http:\/\/leybreeze.com\/blog\/?p=1058\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u52a8\u4f5c\u680f\uff08Action Bar\uff09\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,10],"tags":[98,5,17],"_links":{"self":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1058"}],"collection":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1058"}],"version-history":[{"count":31,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1058\/revisions"}],"predecessor-version":[{"id":1188,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1058\/revisions\/1188"}],"wp:attachment":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1058"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}