建立支持Android包V7的日食 - 网格布局 [英] Setting up Android support package v7 for eclipse - GridLayout
问题描述
我一直想这整个晚上都没有用,所以我会列出我的具体步骤从头开始。
I've been trying this all evening to no avail so I'm going to list my exact steps starting from scratch.
- 我已经安装了通过SDK管理器的支持包。
- 在我创建一个我称之为testinggridlayout一个新的Android项目。
- 在构建目标我选择的是Android 2.1的API 7。
- 项目
这将是我的项目,我希望能够创建一个网格 在布局。
This will be my project which I want to be able to create a grid layout on.
要建立支持包,这些都是我的步骤:
To set up the support package these are my steps:
- 右键单击我刚创建的项目,然后选择 - 新 - Android项目
- 将它命名为网格布局,并选择从现有源创建项目
并浏览到:
- Right-click the project I've just created and select - New - Android Project
- Name it GridLayout and select create project from existing source
and browse to:
Android的软件开发工具包\演员\机器人\ SUPPORT \ V7 \网格布局
android-sdks\extras\android\support\v7\gridlayout
- 右键单击我的
testinggridlayout
项目,然后单击属性: - 在Java构建路径 - 选择项目选项卡,然后添加
- 选择我的项目网格布局,单击确定,然后确定。
- Right-click my
testinggridlayout
project and click properties: - under Java Build Path - select the Projects tab, then Add.
- select my project "GridLayout" and click OK, then Ok.
此时
如果我进入main.xml中布局手动插入该code:
If I go into the main.xml layout manually insert this code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<GridLayout
android:background="#FFFFFF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:columnCount="8"
android:rowCount="5" >
</GridLayout>
</LinearLayout>
我得到的错误:
I get the error:
以下类不能被找到: - 网格布局(修订版本 路径,编辑XML)。
The following classes could not be found: - GridLayout (fix build path, edit XML).
如果我修改
&LT;网格布局&GT; &放大器; &LT; /网格布局&GT;
到
&LT; android.support.v7.widget.GridLayout&GT; &放大器; &LT; /android.support.v7.widget.Gridlayout>
<GridLayout> & </GridLayout>
to
<android.support.v7.widget.GridLayout> & </android.support.v7.widget.Gridlayout>
我收到了同样的错误:
以下类不能被找到: - android.support.v7.widget.GridLayout(固定构建路径,编辑XML)。
The following classes could not be found: - android.support.v7.widget.GridLayout (fix build path, edit XML).
在这一点上,我在我的项目被称为库创建的文件夹。
At that point I created a folder in my project called "libs".
我然后在网格布局项目到这个文件夹复制Android的支持-V7-GridLayout.jar下的文件库。
I then copied the android-support-v7-GridLayout.jar file under libs in the GridLayout project to this folder.
我右键单击该文件,在我的库文件夹中的testinggridlayout,并选择添加到构建路径。
I right clicked this file in my "libs" folder in "testinggridlayout" and selected "Add to Build Path".
我的错误,则改为:
以下类不能被实例化: - android.support.v7.widget.GridLayout(公开课,显示错误日志)
The following classes could not be instantiated: - android.support.v7.widget.GridLayout (open class, show error log)
哪个位(S)有我错过了/不应该这样做?
Which bit(s) have I missed out/ shouldn't have done?
推荐答案
我用的IntelliJ IDEA,所以它不是完全的情况下,但也许这将是有益的。我与设置此整天挣扎着,然后突然的工作。我将描述我的设置,所以你可以比较:
I use intellij idea, so it's not exactly your case, but maybe it will be helpfull. I struggled with setting this up whole day, then it suddenly worked. I'll describe my setup so you can compare:
- 设置网格布局项目作为库项目。设置的例子可以在Android开发者网站这里 找到
- 设置您的主项目像往常一样,在上面的链接描述的引用该库的项目。
- 库添加到主项目。我用最新的
Android的支持 - v13.jar
和Android的支持-V7-gridlayout.jar
。 注意:的我用的是V7支持库在主的项目,而不是库项目。事实上,现在正在检查它 - 库项目中,我的不引用的的V7支持 - 在布局文件中使用全包名称:; android.support.v7.widget.GridLayout /&GT; 而不是
&LT;
&LT网格布局/&GT;
- 使用自定义命名空间,像这样:
的xmlns:格=http://schemas.android.com/apk/res-auto
在布局文件在您的标记使用的库项目定义的自定义属性,如格:列数
- setup the GridLayout project as library project. Example of setting up can be found at android developer site here
- setup your main project as usual, reference the library project as described in the link above.
- add libraries to your main project. I used latest
android-support-v13.jar
andandroid-support-v7-gridlayout.jar
. NOTE: I used the v7 support library in the main project, not the library project. In fact, checking it now - in library project I don't reference the v7 support. - Use full package name in the layout file:
<android.support.v7.widget.GridLayout />
instead of<GridLayout />
- use custom namespace, something like this:
xmlns:grid="http://schemas.android.com/apk/res-auto"
in your layout file to use custom attributes defined in the library project in your tag, likegrid:columnCount
希望这有助于。目前,我想要它,甚至不知道这是我需要的:)
hope this helps. I'm currently trying it, not even sure it is something I need :)
这篇关于建立支持Android包V7的日食 - 网格布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!