web-dev-qa-db-fra.com

"l'aperçu a expiré lors du rendu de la mise en page avec une boucle infinie ou une récursion sans limite" lorsque j'ai dupliqué des tables de table

Je suis en train de créer une application qui fonctionnera comme une feuille de réponses. J'ai gardé TableLayout pour contenir les différentes questions en lignes et leurs choix multiples dans les colonnes
J'ai donc "copié-collé" ce code TableRow 11 fois pour 11 questions

    <TableRow
    Android:layout_height="wrap_content"
    Android:layout_width="wrap_content"
    Android:orientation="horizontal">



    <TextView
        Android:layout_height="wrap_content"
        Android:layout_width="wrap_content"
        Android:text="1"
        Android:textSize="24sp"/>
    <RadioButton
        Android:layout_width="wrap_content"
        Android:layout_height="wrap_content"
        Android:text="A"/>
    <RadioButton
        Android:layout_width="wrap_content"
        Android:layout_height="wrap_content"
        Android:text="B"/>
    <RadioButton
        Android:layout_width="wrap_content"
        Android:layout_height="wrap_content"
        Android:text="C"/>
    <RadioButton
        Android:layout_width="wrap_content"
        Android:layout_height="wrap_content"
        Android:text="D"/>
    <CheckBox
        Android:layout_height="wrap_content"
        Android:layout_width="wrap_content"/>

</TableRow>

Mais il y avait une erreur de rendu disant "boucle infinie ou récursion sans limite"

Mon fichier activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:Android="http://schemas.Android.com/apk/res/Android"
Android:layout_width="wrap_content"
Android:layout_height="wrap_content"
Android:layout_row="5"
Android:layout_column="5"
Android:background="@Android:color/holo_blue_dark">

<TableRow
    Android:layout_height="wrap_content"
    Android:layout_width="wrap_content"
    Android:orientation="horizontal">



    <TextView
        Android:layout_height="wrap_content"
        Android:layout_width="wrap_content"
        Android:text="1"
        Android:textSize="24sp"/>
    <RadioButton
        Android:layout_width="wrap_content"
        Android:layout_height="wrap_content"
        Android:text="A"/>
    <RadioButton
        Android:layout_width="wrap_content"
        Android:layout_height="wrap_content"
        Android:text="B"/>
    <RadioButton
        Android:layout_width="wrap_content"
        Android:layout_height="wrap_content"
        Android:text="C"/>
    <RadioButton
        Android:layout_width="wrap_content"
        Android:layout_height="wrap_content"
        Android:text="D"/>
    <CheckBox
        Android:layout_height="wrap_content"
        Android:layout_width="wrap_content"/>

</TableRow>
<TableRow
    Android:layout_height="wrap_content"
    Android:layout_width="wrap_content"
    Android:orientation="horizontal">



    <TextView
        Android:layout_height="wrap_content"
        Android:layout_width="wrap_content"
        Android:text="1"
        Android:textSize="24sp"/>
    <RadioButton
        Android:layout_width="wrap_content"
        Android:layout_height="wrap_content"
        Android:text="A"/>
    <RadioButton
        Android:layout_width="wrap_content"
        Android:layout_height="wrap_content"
        Android:text="B"/>
    <RadioButton
        Android:layout_width="wrap_content"
        Android:layout_height="wrap_content"
        Android:text="C"/>
    <RadioButton
        Android:layout_width="wrap_content"
        Android:layout_height="wrap_content"
        Android:text="D"/>
    <CheckBox
        Android:layout_height="wrap_content"
        Android:layout_width="wrap_content"/>

</TableRow>



</TableLayout>

Je veux créer quelque chose comme ceci avec 11 questions this

voici la trace de la pile

Java.util.concurrent.TimeoutException: Preview timed out while rendering the layout.
This typically happens when there is an infinite loop or unbounded recursion in one of the custom views.
at Java.util.ArrayList.indexOf(ArrayList.Java:317)
at Java.util.ArrayList.contains(ArrayList.Java:300)
at com.Android.layoutlib.bridge.impl.DelegateManager.addNewDelegate(DelegateManager.Java:132)
at Android.graphics.drawable.VectorDrawable_Delegate.nCreateTree(VectorDrawable_Delegate.Java:94)
at Android.graphics.drawable.VectorDrawable.nCreateTree(VectorDrawable.Java)
at Android.graphics.drawable.VectorDrawable.access$300(VectorDrawable.Java:204)
at Android.graphics.drawable.VectorDrawable$VectorDrawableState.createNativeTree(VectorDrawable.Java:824)
at Android.graphics.drawable.VectorDrawable$VectorDrawableState.access$000(VectorDrawable.Java:761)
at Android.graphics.drawable.VectorDrawable.inflate(VectorDrawable.Java:581)
at Android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.Java:130)
at Android.graphics.drawable.Drawable.createFromXmlInner(Drawable.Java:1224)
at Android.graphics.drawable.Drawable.createFromXml(Drawable.Java:1197)
at com.Android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.Java:316)
at Android.content.res.Resources_Delegate.getDrawable(Resources_Delegate.Java:142)
at Android.content.res.Resources.getDrawable(Resources.Java:763)
at Android.graphics.drawable.AnimatedVectorDrawable.inflate(AnimatedVectorDrawable.Java:373)
at Android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.Java:130)
at Android.graphics.drawable.Drawable.createFromXmlInner(Drawable.Java:1224)
at Android.graphics.drawable.Drawable.createFromXml(Drawable.Java:1197)
at com.Android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.Java:316)
at Android.content.res.BridgeTypedArray.getDrawable(BridgeTypedArray.Java:687)
at Android.graphics.drawable.AnimatedStateListDrawable.parseTransition(AnimatedStateListDrawable.Java:473)
at Android.graphics.drawable.AnimatedStateListDrawable.inflateChildElements(AnimatedStateListDrawable.Java:455)
at Android.graphics.drawable.AnimatedStateListDrawable.inflate(AnimatedStateListDrawable.Java:385)
at Android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.Java:130)
at Android.graphics.drawable.Drawable.createFromXmlInner(Drawable.Java:1224)
at Android.graphics.drawable.Drawable.createFromXml(Drawable.Java:1197)
at com.Android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.Java:316)
at Android.content.res.Resources_Delegate.getDrawable(Resources_Delegate.Java:142)
at Android.content.res.Resources.getDrawable(Resources.Java:763)
at Android.support.v7.widget.ResourcesWrapper.getDrawable(ResourcesWrapper.Java:133)
at Android.content.Context.getDrawable(Context.Java:525)
at Android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.Java:26)
at Android.support.v4.content.ContextCompat.getDrawable(ContextCompat.Java:352)
at Android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.Java:193)
at Android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.Java:181)
at Android.support.v7.widget.AppCompatCompoundButtonHelper.loadFromAttributes(AppCompatCompoundButtonHelper.Java:64)
at Android.support.v7.widget.AppCompatCheckBox.<init>(AppCompatCheckBox.Java:61)
at Android.support.v7.widget.AppCompatCheckBox.<init>(AppCompatCheckBox.Java:54)
at Sun.reflect.GeneratedConstructorAccessor363.newInstance(Unknown Source)
at Sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.Java:45)
at Java.lang.reflect.Constructor.newInstance(Constructor.Java:423)
at org.jetbrains.Android.uipreview.ViewLoader.createNewInstance(ViewLoader.Java:465)
at org.jetbrains.Android.uipreview.ViewLoader.loadClass(ViewLoader.Java:172)
at org.jetbrains.Android.uipreview.ViewLoader.loadView(ViewLoader.Java:105)
at com.Android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.Java:186)
at Android.view.BridgeInflater.loadCustomView(BridgeInflater.Java:312)
at Android.view.BridgeInflater.onCreateView(BridgeInflater.Java:141)
at Android.view.LayoutInflater.onCreateView(LayoutInflater.Java:717)
at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:785)
at Android.view.BridgeInflater.createViewFromTag(BridgeInflater.Java:210)
at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:727)
at Android.view.LayoutInflater.rInflate_Original(LayoutInflater.Java:858)
at Android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.Java:70)
at Android.view.LayoutInflater.rInflate(LayoutInflater.Java:834)
at Android.view.LayoutInflater.rInflateChildren(LayoutInflater.Java:821)
at Android.view.LayoutInflater.rInflate_Original(LayoutInflater.Java:861)
at Android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.Java:70)
at Android.view.LayoutInflater.rInflate(LayoutInflater.Java:834)
at Android.view.LayoutInflater.rInflateChildren(LayoutInflater.Java:821)
at Android.view.LayoutInflater.inflate(LayoutInflater.Java:518)
at Android.view.LayoutInflater.inflate(LayoutInflater.Java:397)
at com.Android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.Java:317)
at com.Android.layoutlib.bridge.Bridge.createSession(Bridge.Java:429)
at com.Android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.Java:389)
at com.Android.tools.idea.rendering.RenderTask$2.compute(RenderTask.Java:548)
at com.Android.tools.idea.rendering.RenderTask$2.compute(RenderTask.Java:533)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.Java:966)
at com.Android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.Java:533)
at com.Android.tools.idea.rendering.RenderTask.lambda$inflate$61(RenderTask.Java:659)
at com.Android.tools.idea.rendering.RenderTask$$Lambda$141/4860208.call(Unknown Source)
at Java.util.concurrent.FutureTask.run(FutureTask.Java:266)
at Java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1142)
at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:617)
at Java.lang.Thread.run(Thread.Java:745)
9
Sushant Baskota

Essaye ça:

Construire -> Reconstruire le projet 

Cela m'aide à me débarrasser de cette erreur. Je n'ai changé aucun de mes codes.

30
peteroid

Pour moi, le redémarrage du studio Android a fonctionné après une construction propre.

2
vinni
  • construire APK 
  • reconstruire le projet

cela fera

2
Riley Bow-t

Aller à une autre mise en page qui n’a pas ce problème, et revenir encore à la mise en page qui faisait face à cette question a fonctionné pour moi.

1
Reejesh PK

accédez à style.xml et changez le parent en tant que Base.Theme.AppCompat.Light.DarkActionBar

0
Vivek Verma