我使用Eclipse,并试图使用来自Lollipop的新support-library-v7:21.+创建一个应用程序。
support-library-v7project-properties中更改了一行:target=android-21和21个目标毕竟,我仍然得到了无效的R声明。我重新启动了Eclipse,然后,在重新导入库之后,似乎就走了!我还创建了一个Tolbar和一个NavigationDrawer,没有问题--它可以工作。
现在,我想在我的CardView项目中添加一个ListView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
>
<!-- A CardView that contains a TextView -->
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="200dp"
card_view:cardCornerRadius="4dp">
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/codename"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/versione"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/link"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/timestamp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</android.support.v7.widget.CardView>
</LinearLayout>嗯,第一个错误:No resource identifier found for attribute 'cardCornerRadius'。我尝试删除该属性,重新启动应用程序,但我得到了以下崩溃:
java.lang.RuntimeException: Binary XML file line #2: You must supply a layout_width attribute.我不明白问题出在哪里。
发布于 2014-11-03 17:21:31
添加库
Gradle
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:cardview-v7:22.0.0'月食
Using android.support.v7.widget.CardView in my project (Eclipse)
真LinearLayout
正如错误说的那样,LinearLayout需要一个layout_width和一个layout_heighth。一直都是。
发布于 2014-11-08 00:10:58
我已经概述了为我工作的步骤,作为对this question的回答。应该管用的。
发布于 2015-03-22 19:21:10
我也有过同样的问题。
尝试添加Eclipse->properies>Android->库->Add= CardView是不存在的。尝试过的Eclipse->properies->JavaBuildPath->Libraries->Add Jars>(从CardView->库中选择)没有工作。
起作用的是:硬视图->Project.properties,如果缺少,添加android.library=true。
https://stackoverflow.com/questions/26719127
复制相似问题