无法将 android.support.v7.widget.CardView 导入 Eclipse

我使用Eclipse,我正在尝试使用Lollipop的新应用程序创建一个应用程序。support-library-v7:21.+

  • 创建了我的新项目
  • 在日食中导入support-library-v7
  • 更改了支持库中的行:具有 21 个目标project-propertiestarget=android-21
  • 在 21 中更改了我的应用程序的目标
  • 在我的项目中导入了库
  • 全部清理干净

毕竟我仍然得到了无效的声明。我重新启动了Eclipse,然后在重新导入库后,似乎去了!我创建了一个和一个也没有问题 - 它的工作原理。RTolbarNavigationDrawer

现在,我想在我的物品中放一个:CardViewListView

<?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.

我不明白问题出在哪里。


答案 1

添加库

格雷德尔

compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:cardview-v7:22.0.0'

日蚀

在我的项目中使用 android.support.v7.widget.CardView (Eclipse)

正确的线性布局

正如错误所说,a 需要 a 和 a 。总是。LinearLayoutlayout_widthlayout_heighth


答案 2

我已经概述了对我有用的步骤,作为这个问题的答案。它应该有效。


推荐