本文介绍了为什么在使用moondroid Coverflow时出现NullPointerException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我是android开发的初学者,我使用 moondroid CoverFlow (外部库)进行创建CoverFlow,但是我不明白为什么在XML中使用它时会出现空指针异常.

I am a beginner in android development, I am using moondroid CoverFlow (external library) to create a CoverFlow, but I don't get why I am getting a null pointer exception when using it in XML.

这是我的XML文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  xmlns:coverflow="http://schemas.android.com/tools">

   <it.moondroid.coverflow.components.ui.containers.FeatureCoverFlow
      android:id="@+id/coverflow"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      coverflow:coverHeight="@dimen/cover_height"
      coverflow:coverWidth="@dimen/cover_width"
      coverflow:maxScaleFactor="1.5"
      coverflow:reflectionGap="0px"
      coverflow:rotationThreshold="0.5"
      coverflow:scalingThreshold="0.5">

   </it.moondroid.coverflow.components.ui.containers.FeatureCoverFlow>

</RelativeLayout>

这是我得到的错误是:

java.lang.NullPointerExceptio at it.moondroid.coverflow.components.ui.containers.FeatureCoverFlow.dispatchDraw(FeatureCoverFlow.java:471)
at android.view.View.draw(View.java:16974)   at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)   at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)   at android.view.ViewGroup.drawChild(ViewGroup.java:3764)   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)   at android.view.View.draw(View.java:16974)   at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)   at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)   at android.view.ViewGroup.drawChild(ViewGroup.java:3764)   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)   at android.view.View.draw(View.java:16974)   at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)   at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)   at android.view.ViewGroup.drawChild(ViewGroup.java:3764)   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)   at android.view.View.draw(View.java:16974)   at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)   at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)   at android.view.ViewGroup.drawChild(ViewGroup.java:3764)   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)   at android.view.View.draw(View.java:17071)

推荐答案

只看一下这样设置的示例

Just take a look at the sample example it is set like this

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:coverflow="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
tools:context="it.moondroid.carousellayoutdemo.CoverFlowActivity">


<it.moondroid.coverflow.components.ui.containers.FeatureCoverFlow
    android:id="@+id/coverflow"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    coverflow:coverHeight="@dimen/cover_height"
    coverflow:coverWidth="@dimen/cover_width"
    coverflow:maxScaleFactor="1.5"
    coverflow:reflectionGap="0px"
    coverflow:rotationThreshold="0.5"
    coverflow:scalingThreshold="0.5"
    coverflow:spacing="0.6" />

<TextSwitcher
    android:id="@+id/title"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="16dp"
    android:layout_alignParentBottom="true"
    android:layout_centerVertical="true" />

</RelativeLayout>

并添加一些其他文件像这样只需看看示例

and add some additional file like thisJust take a look at the sample too

这篇关于为什么在使用moondroid Coverflow时出现NullPointerException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 08:55