我想使用已与新的Android L移动开发者预览版支持库介绍(如提到的新CardView小部件在这里),这似乎是V7支持库的一个新版本的一部分.
我现在更新了我的SDK版本,下载了最新的Support Library软件包,但我仍然找不到新的CardView小部件.
我已经搜索了网络和官方文档,但无法获得有关我可以获得新支持库的任何提示.
任何帮助都非常感谢!
编辑:我正在使用ADT/Eclipse
您好我正在使用演示应用程序,我正在使用支持库的卡片视图.默认情况下,它会在它周围添加阴影.我想删除这个阴影,看起来应该很简单.
我试过这个对我不起作用.
CardView cardView = (CardView) v.findViewById(R.id.cardView);
cardView.setElevation(0);
Run Code Online (Sandbox Code Playgroud)
做完这些之后我就崩溃了
11-06 15:12:17.018: E/AndroidRuntime(24315): FATAL EXCEPTION: main
11-06 15:12:17.018: E/AndroidRuntime(24315): Process: com.xyz, PID: 24315
11-06 15:12:17.018: E/AndroidRuntime(24315): java.lang.NoSuchMethodError: android.support.v7.widget.CardView.setElevation
11-06 15:12:17.018: E/AndroidRuntime(24315): at com.xyz.adapters.RecycleViewAdapter.onCreateViewHolder(RecycleViewAdapter.java:85)
11-06 15:12:17.018: E/AndroidRuntime(24315): at com.xyz.adapters.RecycleViewAdapter.onCreateViewHolder(RecycleViewAdapter.java:1)
11-06 15:12:17.018: E/AndroidRuntime(24315): at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:2915)
11-06 15:12:17.018: E/AndroidRuntime(24315): at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:2511)
11-06 15:12:17.018: E/AndroidRuntime(24315): at android.support.v7.widget.LinearLayoutManager$RenderState.next(LinearLayoutManager.java:1425)
11-06 15:12:17.018: E/AndroidRuntime(24315): at android.support.v7.widget.LinearLayoutManager$RenderState.next(LinearLayoutManager.java:1425)
Run Code Online (Sandbox Code Playgroud)
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res/com.xyz"
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="horizontal" >
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我想在我的项目中使用CardView,但是当我运行我的应用程序时,我收到以下错误.我正在使用Eclipse.
Error: Error inflating class and android.support.v7.widget.CardView
The graphical view of my xml file says 'The following classes could not be instantiated:
- android.support.v7.widget.CardView (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.'
Run Code Online (Sandbox Code Playgroud)
请帮忙.
这是我使用过的片段的布局 CardView
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.log.MyContactsFragment" >
<!-- TODO: Update blank fragment layout -->
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/cvContactDetails"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_gravity="center"
android:background="?android:attr/selectableItemBackground"
android:clickable="false"
android:elevation="20dp" >
<TextView
android:id="@+id/tvContacts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Contact Info" />
<Button
android:id="@+id/bDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud) eclipse android android-cardview android-5.0-lollipop android-recyclerview