虽然回答晚了,但对于未来需要在GridLayout
(或者ActionBarActivity
/AppCompat
)添加支持库和资源的人来说,以下是最简单的方法。
确保你已经安装了Android Support Library,可以从Android SDK Manager中安装。
在IDEA中:打开你的项目,然后选择File
/ Import Module
{SDK}\extras\android\support\v7\gridlayout
Import module from external model
和Eclipse
Create module files near .classpath files
,或者选择其他地方,如果你不想写入到SDK路径中的话Select Eclipse projects to import
和android-support-v7-gridlayout
,IDEA还会询问你是否要重新加载项目。gridlayout [android-support-v7-gridlayout]
。现在你需要更新你的项目依赖到这个模块中的资源,并添加.jar库。选择File
/ Project Structure
Modules
项目设置,然后选择你的项目(在下图中是testv7)Dependencies
+
按钮,添加一个Module dependency...
到android-support-v7-gridlayout
。{SDK}\extras\android\support\v7\gridlayout\libs
(或其中的 .jar 文件)的 Jars 或 directories…
。如果您还打算使用 v4 版本,请选择 {SDK}\extras\android\support\v7\appcompat\libs
,因为它包含了 v4 和 v7 两个版本的 jar 包。
然后您就可以正常使用了。
对我来说,这是解决与 ActionBarActivity
相似问题的唯一方法,该问题可以在 {SDK}\extras\android\support\v7\appcompat
模块上使用相同的技术解决。我尝试过其他几种方法 ;)
build.gradle
文件中添加:dependencies {
...
compile 'com.android.support:gridlayout-v7:23.1.+'
}
一切应该都能正常工作 :)
如果您正在使用Android Studio,只需转到Gradle Script -> build.gradle(Module:app) -> dependencies,并在那里输入这些依赖项以获得更好的支持。
compile 'com.android.support:gridlayout-v7:23.0.2'
compile 'com.android.support:appcompat-v7:+'
提示:版本“v7:23.0.2”依赖于您的最新构建工具。
希望这可以帮到您。