﻿{"id":1773,"date":"2012-02-09T16:45:47","date_gmt":"2012-02-09T08:45:47","guid":{"rendered":"http:\/\/blog.jixin.ntxz.net\/?p=1773"},"modified":"2012-02-09T16:45:47","modified_gmt":"2012-02-09T08:45:47","slug":"%e6%80%8e%e6%a0%b7%e4%bd%bf%e7%94%a8linearlayout%e7%9a%84buttonbar%e6%a0%b7%e5%bc%8f","status":"publish","type":"post","link":"http:\/\/www.ntxz.net\/?p=1773","title":{"rendered":"\u600e\u6837\u4f7f\u7528LinearLayout\u7684ButtonBar\u6837\u5f0f"},"content":{"rendered":"<p>\u770b\u5230\u5f88\u591a\u8f6f\u4ef6\u5728\u5e95\u90e8\u6709\u4e00\u6392\u6309\u94ae\uff0c\u4e8e\u662f\u4fbf\u7814\u7a76\u8fd9\u4e2a\u662f\u600e\u4e48\u5b9e\u73b0\u7684\uff0c\u5728android\u4e2d\u5e76\u6ca1\u6709\u73b0\u6210\u7684\u63a7\u4ef6\u53ef\u7528\uff0c\u641c\u7d22\u7f51\u4e0a\u6709\u4eba\u8bf4\u7528LinearLayout\u7684ButtonBar\u6837\u5f0f\u53ef\u4ee5\u5b9e\u73b0\uff0c\u4e0b\u9762\u4fbf\u6765\u8bf4\u660e\u4e0b\u7528\u6cd5\u548c\u5b9e\u73b0\u3002<\/p>\n<p>\u4e0d\u8fc7\u8fd9\u91cc\u8bf4\u4e00\u4e0b\uff0c\u5728Api\u6587\u6863\u91cc\u6211\u662f\u6ca1\u6709\u627e\u5230\u8bf4\u660e\u8fd9\u4e2aButtonBar\u7684\u5730\u65b9\uff0c\u5982\u679c\u6709\u77e5\u9053\u7684\u8fd8\u8bf7\u6307\u70b9\u4e00\u4e0b\u3002<\/p>\n<p>\u9996\u5148\u5728XML\u4e2d\u5b9a\u4e49\u8fd9\u4e2aLinearLayout\uff0c\u6ce8\u610f\u8fd9\u53e5style=&#8221;@android:style\/ButtonBar&#8221;\uff0c\u5c06\u8fd9\u4e2aLinearLayout\u5b9a\u4e49\u4e3aButtonBar\u7684\u6837\u5f0f\u3002<\/p>\n<pre class=\"brush: xml\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\r\n&lt;LinearLayout xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;\r\n        android:orientation=&quot;vertical&quot;\r\n        android:layout_width=&quot;fill_parent&quot;\r\n        android:layout_height=&quot;fill_parent&quot;&gt;\r\n    &lt;ViewFlipper android:id=&quot;@+id\/flipper&quot;\r\n        android:layout_width=&quot;fill_parent&quot;\r\n        android:layout_height=&quot;wrap_content&quot;\r\n        android:layout_marginBottom=&quot;20dip&quot; \r\n        android:layout_weight=&quot;1&quot;&gt;\r\n    &lt;\/ViewFlipper&gt;\r\n    \r\n    &lt;LinearLayout\r\n\t\tstyle=&quot;@android:style\/ButtonBar&quot;\r\n\t\tandroid:layout_width=&quot;fill_parent&quot;\r\n\t\tandroid:layout_height=&quot;wrap_content&quot;\r\nandroid:padding=&quot;0dip&quot;\r\nandroid:paddingLeft=&quot;0dip&quot;\r\n\t\tandroidrientation=&quot;horizontal&quot;&gt;\r\n\t\t&lt;ImageButton\r\n\t\t\tandroid:id=&quot;@+id\/button_library_1&quot;\r\n\t\t \t android:src=&quot;@drawable\/button1&quot;\r\n\t\t\tandroid:padding=&quot;0dip&quot;\r\n\t\t\t\t\tandroid:layout_margin=&quot;0dip&quot;\r\n\t\t\t\t\tandroid:layout_marginLeft=&quot;0dip&quot;\r\n\t\t\t\t\tandroid:layout_marginRight=&quot;0dip&quot;\r\n\t\t\tandroid:layout_width=&quot;wrap_content&quot;\r\n\t\t\tandroid:layout_height=&quot;wrap_content&quot;\r\n\t\t\t\/&gt;\r\n\t\t&lt;ImageButton\r\n\t\t\tandroid:id=&quot;@+id\/button_picture_1&quot;\r\n\t\t\tandroid:src=&quot;@drawable\/button2&quot;\r\n\t\t\tandroid:padding=&quot;0dip&quot;\r\n\t\t\t\t\tandroid:layout_margin=&quot;0dip&quot;\r\n\t\t\t\t\tandroid:layout_marginLeft=&quot;0dip&quot;\r\n\t\t\t\t\t\r\n\t\t\tandroid:layout_width=&quot;wrap_content&quot;\r\n\t\t\tandroid:layout_height=&quot;wrap_content&quot;\r\n\t\t\t\/&gt;\r\n\t&lt;\/LinearLayout&gt;\r\n&lt;\/LinearLayout&gt;\r\n<\/pre>\n<p>\u8fd9\u91cc\u52a0\u4e86\u4e00\u4e2aviewFlipper\uff0c\u5f53\u6309\u94ae\u6309\u4e0b\u53bb\u65f6\u4f7f\u7528\u5b83\u6765\u505a\u754c\u9762\u5207\u6362\uff0c\u5728\u5185\u5c42\u7684LinearLayout\u4e2d\u6211\u4f7f\u7528\u4e86\u4e24\u4e2aImageButton,\u4e5f\u53ef\u4ee5\u4f7f\u7528Button,\u968f\u610f\u5b9a\u4e49\u5373\u53ef\u3002<\/p>\n<p>\u4ee3\u7801\u4e2d\u53ea\u9700\u8981\u5c06\u4e24\u4e2aView\u6dfb\u52a0\u5230ViewFlipper\u4e2d\uff0c\u7136\u540e\u5c06\u4e24\u4e2aImageButton\u7684OnClickListener\u5206\u522b\u5b9a\u4e49\u4e3a\u663e\u793a\u521a\u521a\u6dfb\u52a0\u7684\u4e24\u4e2aView\u5373\u53ef\u3002\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush: java\">\r\npublic class TabTest extends Activity {\r\n\tViewFlipper vf;\r\n\tImageButton b1,b2;\r\n\tpublic void onCreate(Bundle savedInstanceState) {\r\n\t\tsuper.onCreate(savedInstanceState);\r\n\t\tsetContentView(R.layout.tabtest);\r\n\t\t\r\n\t\tLayoutInflater li = this.getLayoutInflater();\r\n\t\tView view = li.inflate(R.layout.flip1, null);\r\n\t\t\r\n\t\tTextView tv = new TextView(this);\r\n\t\ttv.setText(&quot;test text&quot;);\r\n\t\t\r\n\t\tvf = (ViewFlipper) findViewById(R.id.flipper);\r\n\t\tvf.addView(view,0);\r\n\t\tvf.addView(tv,1);\r\n\t\t\r\n\t\tb1 = (ImageButton)findViewById(R.id.button_library_1);\r\n\t\tb2 = (ImageButton)findViewById(R.id.button_picture_1);\r\n\t\tb1.setBackgroundDrawable(null);\r\n\t\tb1.setOnClickListener(new View.OnClickListener() {\r\n\t\t\tpublic void onClick(View v) {\r\n\t\t\t\tvf.setDisplayedChild(0);\r\n\t\t\t}\r\n\t\t});\r\n\t\tb2.setOnClickListener(new View.OnClickListener() {\r\n\t\t\tpublic void onClick(View v) {\r\n\t\t\t\tvf.setDisplayedChild(1);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\t\r\n}\r\n<\/pre>\n<p>\u8fd9\u53ea\u662f\u4e00\u4e2a\u5f88\u7b80\u964b\u7684\u5b9e\u73b0\uff0c\u8fd8\u9700\u8981\u5f88\u591a\u7f8e\u5316\u5de5\u4f5c\uff0c\u8fd9\u91cc\u4e0d\u8be6\u8ff0\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u770b\u5230\u5f88\u591a\u8f6f\u4ef6\u5728\u5e95\u90e8\u6709\u4e00\u6392\u6309\u94ae\uff0c\u4e8e\u662f\u4fbf\u7814\u7a76\u8fd9\u4e2a\u662f\u600e\u4e48\u5b9e\u73b0\u7684\uff0c\u5728android\u4e2d\u5e76\u6ca1\u6709\u73b0\u6210\u7684\u63a7\u4ef6\u53ef\u7528\uff0c\u641c\u7d22\u7f51\u4e0a\u6709\u4eba [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[346],"tags":[503,502],"class_list":["post-1773","post","type-post","status-publish","format-standard","hentry","category-android","tag-buttonbar","tag-linearlayout"],"views":696,"_links":{"self":[{"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/posts\/1773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1773"}],"version-history":[{"count":1,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/posts\/1773\/revisions"}],"predecessor-version":[{"id":1774,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/posts\/1773\/revisions\/1774"}],"wp:attachment":[{"href":"http:\/\/www.ntxz.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1773"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}