[Android: How to Use actionbar-actionbarsherlock in Android 2.x

Source: Internet
Author: User
1. Example description
    • Since Android 3.0, Android has introduced actoinbar. It must be said that before Android 3.0, the title bar of Android is really ugly and there is no function yet.
    • In the past, the top columns of many applications were similar to Apple, for example. With the release and gradual expansion of Android 4.0 and Android 4.2, many applications have begun to use the uidesign promoted by Google, and actionbar is a very important part.
    • Google has not released the actionbar compatibility package for versions earlier than 3.0. Fortunately, the Internet provides open-source development by others, actionbarshelock, or ABS for short.
    • Another advantage of ABS is that if you use it on more than 3.0 machines, it will call the system's native actionbar. In addition, its usage method is quite similar to the system's own method. If you are familiar with actionbar itself, ABS can also get started quickly.
    • Http://actionbarsherlock.com/download the corresponding compressed package

 

2. Running result

3. CoreCode
 
@ Overrideprotected void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); getsuppactionactionbar (). setdisplayhomeasupenabled (true);} @ overridepublic Boolean oncreateoptionsmenu (COM. actionbarsherlock. view. menu) {getsupportmenuinflater (). inflate (R. menu. main, menu); return Super. oncreateoptionsmenu (menu);} @ overridepublic Boolean onoptionsitemselected (Menuitem item) {Switch (item. getitemid () {case R. Id. menu_settings: Toast. maketext (this, "actionbarsherlock settings! ", Toast. length_long). Show (); break; case R. Id. homeasup: Toast. maketext (this," Home! ", Toast. length_long). Show (); break;} return Super. onoptionsitemselected (item );}

 

4. Precautions

 

1. Your project buildtarget must be in the range of 4.0 + and API 14 +. Otherwise, the theme. holo XML file cannot read resources, and the r file cannot be generated.

2. Because actionbarsherlock contains the android_support_v4 package, you do not need to import another package. If you have previously imported the package, you must delete it. Otherwise, a conflict may occur.

3. Sometimes you will be promptedProgramIt is not a library error. You only need to check the islibrary in Properties> android in actionbarsherlock.

4. To use actionbar to inherit from sherlockactivity, you must add theme settings when declaring activity in the configuration file, and there are only three types of theme and three types of parents.

 

5. Watch the video to explain Http://www.eyeandroid.com/thread-11914-1-1.html
 
Related Article

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.