为什么每当我创建一个新项目时,Eclipse都会自动添加appcompat v7库支持?

我正在创建一个简单的项目,它的MainActivity应该扩展Activity,但它没有。Eclipse自动添加操作栏支持。

我如何创建一个简单的项目没有appcompat库?供您参考,我已经下载了最新版本的ADT,最近更新了所有内容。我使用的是windows7 x64。


当前回答

如果你的目标不是2。X版本,你可以设置你的最低SDK版本为4。X,然后创建项目。不会创建Appcompat V7库。

其他回答

如果你的目标不是2。X版本,你可以设置你的最低SDK版本为4。X,然后创建项目。不会创建Appcompat V7库。

创建一个新的Android应用程序项目,取消第二步(配置项目)中的创建活动。

根据http://developer.android.com/guide/topics/ui/actionbar.html

ActionBar API最初是在Android 3.0 (API级别11)中添加的,但它们也可以在支持库中使用,以兼容Android 2.1 (API级别7)及以上。

简而言之,你所看到的自动生成项目模块化了将ActionBar添加到api 7-10的过程。

有关该主题的简化解释和教程,请参阅http://hmkcode.com/add-actionbar-to-android-2-3-x/。

我注意到在创建ADT 22.6.2版本的新android项目时创建了“appcompat”库,即使minSDK设置为11,targetSDK设置为19

这是因为,在新的项目模板中,android正在使用一些来自支持库的属性。例如,如果一个新项目是用actionbar创建的,那么在菜单的main.xml中,你可以从支持库中找到app:showAsAction="never"。

If the app is targeted at android version 11 and above then one can change this attribute to android:showAsAction in menu's main.xml Also the default theme set could be "Theme.AppCompat.Light.DarkActionBar" as shown below (styles.xml) <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- API 14 theme customizations can go here. --> </style> In this case the parent theme in style.xml has to be changed to "android:style/Theme.Holo.Light.DarkActionBar" In addition to this if reference to Fragment,Fragments Manager from support library was made in the code of MainActivity.java, these have to appropriately changed to Fragment, FragmentManager of the SDK.

当你创建一个新的android项目时,你应该选择高级别的api,例如:从api 17到api 21,它不会有appcompat,很容易共享项目。 如果你用较低的API,你只需要在Android Manifest中编辑有较高的API:),之后,你可以删除Appcompat V7。