Aller au contenu

Enfant d'un groupe d'un ExpandableListView et LayoutParams


Fluckysan

Recommended Posts

Bonjour,

Lors du getChildView de mon ExpandableListAdapter je inflate une vue que je retourne

Or je me rend compte que ma vue ne remplie pas toute la largeur de l'ExpandableListView malgré le FILL_PARENT

J'essaye donc de forcer la vue en FILL_PARENT pour le width :

    public View getChildView(final int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
       View view = ViewGroup.inflate(mContext, R.layout.timeline_child_phone, 
...

               view.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

       return view;
   }

Mais mon appli crash :

07-07 15:14:07.559: ERROR/AndroidRuntime(21405): Uncaught handler: thread main exiting due to uncaught exception
07-07 15:14:07.568: ERROR/AndroidRuntime(21405): java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.widget.ListView.measureScrapChild(ListView.java:1068)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.widget.ListView.measureHeightOfChildren(ListView.java:1149)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.widget.ListView.onMeasure(ListView.java:1060)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.view.View.measure(View.java:7964)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.view.View.measure(View.java:7964)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:464)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.view.View.measure(View.java:7964)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.view.View.measure(View.java:7964)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.view.ViewRoot.performTraversals(ViewRoot.java:763)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.os.Looper.loop(Looper.java:123)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at android.app.ActivityThread.main(ActivityThread.java:4363)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at java.lang.reflect.Method.invokeNative(Native Method)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at java.lang.reflect.Method.invoke(Method.java:521)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-07 15:14:07.568: ERROR/AndroidRuntime(21405):     at dalvik.system.NativeStart.main(Native Method)

J'ai essayé avec ViewGroup.LayoutParams et FrameLayout.LayoutParams avec le même résultat crash

Le problème survient uniquement quand je spécifie un LayoutParams, ça fonctionne bien sans (mais ça ne remplie par horizontalement :/)

Lien vers le commentaire
Partager sur d’autres sites

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

×
×
  • Créer...