Android Rookie's Growth Note (--google) official Actionbar support for Andoird 2.x

Source: Internet
Author: User
<span id="Label3"></p><p><p>In Google's official Android design Guide (link: http://www.apkbus.com/design/get-started/ UI-OVERVIEW.HTML) has a new feature is self-identification, that is, to advertise themselves, so a lot of applications are now also natural use of actionbar and provide their own logo.</p></p><p><p>Application Of:</p></p><p><p><br></p></p><p><p>This is what Google's Android Design guide says: the App's launch icon is the <span style="color:#ff0000;">best place</span> to showcase your logo as an entry point for launching your app. You can also place the launch icon on the action Bar to ensure that it is visible on all pages within the app.</p></p><p><p>At the time of using actionbar. Will find a Problem.</p></p><p><p>Actionbar is not supported in the 3.0 sdk, so it would be necessary to use an open source project Actionbarsherlock If the phone apk is compatible with a 2.2 or 2.3 phone, for example, the following:</p></p><p><p>1. Download Open Source Package: http://actionbarsherlock.com/usage.html</p></p><p><p>2. Import into Eclipse (and import the project step again, check the is Library)</p></p><p><p><br></p></p><p><p>3, reference in the project (<span style="color: rgb(51, 51, 51); font-family: ‘Microsoft YaHei‘, Tahoma, Helvetica, SimSun, sans-serif; font-size: 14px; line-height: 21px;">properties->android->add add</span> in)</p></p><p><p><br></p></p><p><p>4. Change the subject to @style/theme.sherlock.light (or its Sub-category)</p></p><p><p>5, Inherit Sherlockactivity.</p></p><p><p></p></p><p><p>6. Use Getsupportactionbar () to get the Actionbar Object.</p></p><p><p></p></p><p><p>The above method is able to realize the problem of using Actionbar for the low version number. But Goole introduced its own Compatibility Pack last year, which is more convenient to Use. Let's take a look at how to use the support_v7.</p></p><p><p></p></p><p><p>1. Download and import the appcompat_7.x Compatibility Pack as above (assuming the official latest SDK development tools are Available)</p></p><p><p>2. References in the Project:</p></p><p><p></p></p><p><p>watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvzgf3yw5nyw5iyw4=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast "/><br></p></p><p><p>3. Change the subject to @style/theme.appcompat (or its Sub-category)</p></p><p><p>4. Change the corresponding XML file under the Menu/folder</p></p><p><p></p></p><pre code_snippet_id="356436" snippet_file_name="blog_20140521_1_4358822" name="code" class="html"><?<p><p></p></p><p>XML version= "1.0" encoding= "utf-8"?> <menu xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:a Lpha= "http://schemas.android.com/apk/res-auto" > <!--Search, should appear as action button--< Item android:id= "@+id/action_search" android:icon= "@drawable/ic_action_refresh" android:title= "brush New "alpha:showasaction="/> <!--Settings, should always being in the overflow-< Item android:id= "@+id/action_add" android:title= "share" android:icon= "@drawable/ic_action_share" alpha:showasaction= "always"/> <item android:id= "@+id/action_settings" android:tit le= "many other" android:icon= "@drawable/ic_action_overflow" alpha:showasaction= "always" > <menu > <group > <item android:id= "@+id/item1" Androidoid:title= "personal center" android:icon= "@drawable/ic_action_share"/> <item android:id= "@+id/item2" android:title= "set" android:icon= "@dr Awable/ic_action_share "/> <item android:id=" @+id/exit_system " android:title= "exit" android:icon= "@drawable/ic_action_share"/> </gr oup> </menu> </item> </menu></p></pre>5. Inherit from actionbaractivity<p><p></p></p><p><p>6. Use Getsupportactionbar to get Actionbar objects.</p></p><p><p></p></p><pre code_snippet_id="356436" snippet_file_name="blog_20140521_2_4980486" name="code" class="java"><pre code_snippet_id="356436" snippet_file_name="blog_20140521_2_4980486" name="code" class="java">ActionBar ActionBar = Getsupportactionbar (); actionbar.setdisplayshowhomeenabled (true); Actionbar.seticon ( r.drawable.actionbar_icon);</pre></pre><br>Perfect execution on Android 2.2 and 2.3 phones ...<br><br><p><p></p></p><p><p><br></p></p> <p><p>Android Rookie's Growth Note (--google) official Actionbar support for Andoird 2.x</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.