【问题标题】:Error inflating Coverflow膨胀 Coverflow 时出错
【发布时间】:2013-08-16 09:37:41
【问题描述】:

我一直试图让这个小部件在我的 Android 项目中工作:https://code.google.com/p/android-coverflow/source/browse/

它被称为 Coverflow,它在某种程度上取代了旧的 Gallery 小部件。在出现错误之前,实现它似乎很简单:

 08-16 17:33:08.289: E/AndroidRuntime(15031): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class pl.polidea.coverflow.CoverFlow

这是错误所指的 XML 文件:

 <pl.polidea.coverflow.CoverFlow class="pl.polidea.coverflow.CoverFlow"
    android:id="@+id/coverflow"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dip" >
</pl.polidea.coverflow.CoverFlow>

这个问题之前在 StackOverflow 上被问过,但这里给出的答案:Android coverflow : Error inflating class pl.polidea.coverflow.CoverFlow 对我不起作用。

【问题讨论】:

  • 您已经为coverflow 定义了一个新视图作为自定义..所以不要再给类名了。
  • 好吧,我已经尝试删除类部分,同样的错误。
  • 你为此创建了一个类吗?
  • 是的,该类与我所指的包完全相同。

标签: android coverflow inflate-exception


【解决方案1】:

你应该这样使用:

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <view class="pl.polidea.coverflow.CoverFlow" xmlns:coverflow="http://schemas.android.com/apk/res/pl.polidea.coverflow"
            coverflow:imageWidth="100dip" coverflow:imageHeight="150dip" android:id="@+id/coverflow" android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:layout_marginTop="5dip">
    </view>

    <pl.polidea.coverflow.CoverFlow xmlns:coverflow="http://schemas.android.com/apk/res/pl.polidea.coverflow"
            coverflow:imageWidth="100dip" coverflow:imageHeight="150dip"   coverflow:withReflection="true"
            coverflow:imageReflectionRatio="0.2" coverflow:reflectionGap="2dip"   android:id="@+id/coverflowReflect"
            android:layout_width="fill_parent" android:layout_height="wrap_content"   android:layout_marginTop="5dip" />

    <TextView android:text="STATUS" android:layout_width="fill_parent"   android:layout_height="wrap_content"
            android:padding="5dip" android:id="@+id/statusText"></TextView>

</LinearLayout>

【讨论】:

  • 是的,这是原始示例项目的副本,奇怪的是这个给了我完全相同的错误。
【解决方案2】:

确保“pl.polidea.coverflow.CoverFlow”是你的类文件(包+java类)... 否则将 xml 中的“pl.polidea.coverflow.CoverFlow”替换为具有coverflow 的实际类文件!

【讨论】:

  • 这是文件的实际位置。我开始认为这个小部件已经过时了,根本不再工作了..
  • 你的类文件CoverFlow.java的包名是什么
  • 你在那个类中也给了相同的xml文件名吗?
  • 是的,该类引用了main.xml,这是XML文件的名称。
  • 类扩展 viewGroup rit
猜你喜欢
  • 2016-09-20
  • 2016-07-02
  • 2016-12-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多