gpt4 book ai didi

java - appcompat_v7 和 android-support-v7-appcompat 之间的区别?

转载 作者:太空宇宙 更新时间:2023-11-03 10:19:28 25 4
gpt4 key购买 nike

人们说它们是相同的,但它们在不同的情况下使用,如 developer site 中所述

1-添加没有资源的库

To add a Support Library without resources to your application project:

Make sure you have downloaded the Android Support Library using the SDK Manager.
Create a libs/ directory in the root of your application project.
Copy the JAR file from your Android SDK installation directory (e.g., <sdk>/extras/android/support/v4/android-support-v4.jar) into your application's project libs/ directory.

2-添加带资源的库

To add a Support Library with resources (such as v7 appcompat for action bar) to your application project:

Make sure you have downloaded the Android Support Library using the SDK Manager.
Create a library project and ensure the required JAR files are included in the project's build path:
Select File > Import.
Select Existing Android Code Into Workspace and click Next.
Browse to the SDK installation directory and then to the Support Library folder. For example, if you are adding the appcompat project, browse to <sdk>/extras/android/support/v7/appcompat/.
Click Finish to import the project. For the v7 appcompat project, you should now see a new project titled android-support-v7-appcompat.
In the new library project, expand the libs/ folder, right-click each .jar file and select Build Path > Add to Build Path. For example, when creating the the v7 appcompat project, add both the android-support-v4.jar and android-support-v7-appcompat.jar files to the build path.
Right-click the library project folder and select Build Path > Configure Build Path.
In the Order and Export tab, check the .jar files you just added to the build path, so they are available to projects that depend on this library project. For example, the appcompat project requires you to export both the android-support-v4.jar and android-support-v7-appcompat.jar files.
Uncheck Android Dependencies.
Click OK to complete the changes.
You now have a library project for your selected Support Library that you can use with one or more application projects.

什么时候应该使用 appcompat_v7(随项目自动生成)以及何时使用 android-support-v7-appcompat ?

在什么情况下程序员需要用项目中的资源添加库?

请告诉我你的经验

最佳答案

android-support-v7-appcompat.jar 是一个 JAR 文件,只包含已编译的 Java 类。 appcompat_v7 是一个库项目,它包含以前的 JAR 文件,没有实际的源代码,以及大量资源(布局、图像等)。

appcompat-v7 的特殊情况下,您需要使用库项目,因为它包含必要的 UI 资源。

其他库(如v7 MediaRouter或v7 Palette)不包含这些资源,因此可以直接使用JAR文件。

请注意,差异主要适用于 Eclipse(其中包含资源的库必须作为项目导入,而其他库只需放在 libs 文件夹中)。在 Android Studio/gradle 中,这一切都由构建系统处理,因此两者的过程是相同的。这在 Support Library Setup 中得到了很好的解释。文档。

关于java - appcompat_v7 和 android-support-v7-appcompat 之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26743524/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com