Android Create item Actionbar (action Bar) does not display the issue

Source: Internet
Author: User

When I created a new project last night, I found that I wanted to create a project with an action bar, no matter how I set it up.

When the project was created, I chose

But open run or no action bar

But looking at other items, androidmanifest.xml files and styles.xml files and other layout file codes are the same, why do other items show up?

Looked for a long time did not solve. Finally found the answer in the book.

Another version-compatible issue (recently encountered with N-many similar problems), the Action Bar component was introduced in Android 3.0 (API 11), which is a navigation panel that replaces the title bar above each activity.

That is, if any activity uses the (default) Theme.holo theme, and its application's target (or minimum SDK) version is 11 or higher, its action bar is enabled.

Look at my other projects minsdk are more than 17, the new MINSDK is 8, naturally also do not enable action bar.

We can control Actionbar,actionbar from API 11, and have not yet provided a support package for this, so when using Actionbar under API 8, the system will error, you can add the following code in the OnCreate method:

if (Build.VERSION.SDK_INT >= build.version_codes. Honeycomb) {ActionBar ActionBar = Getactionbar ();//Actionbar.setsubtitle (subtitle);}
Add the following annotations before the OnCreate method:

@TargetApi (11)
This will create Actionbar only if the API is above 11


Android Create item Actionbar (action Bar) does not display the issue

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.