2016-11-08 2 views
1

Je suis un débutant dans le développement android, j'utilise moondroid CoverFlow (bibliothèque externe) pour créer un CoverFlow, mais je ne comprends pas pourquoi j'obtiens une exception de pointeur nul en l'utilisant en XML.Pourquoi est-ce que j'obtiens une exception NullPointerException en utilisant Moondroid Coverflow?

Voici mon fichier 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> 

Et voici l'erreur que je reçois est:

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) 
+0

Nous aurions besoin de plus stacktace et le code pour aider – Emmanuel

+0

@Emmanuel J'ai fourni la pile restante trace – Abhinav422

Répondre

0

Il suffit de prendre un coup d'oeil à l'exemple échantillon, il est défini comme celui-ci

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

et ajouter un fichier supplémentaire like this Jetez un oeil à la sample too

+0

l'erreur persiste encore – Abhinav422

+0

vous obtenez la ligne rouge dans le fichier XML? ajoutez votre code java –

+0

ok le programme s'exécute, merci beaucoup – Abhinav422