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