tengo un diseño de tablero que tiene varias imágenes. Cuando ejecuto la aplicación, obtengo un error forzar cerrar y el error apunta a esta línea en el panel avtivty donde se infla el diseño (es decir, setContentView (R.layout.dashboard). No entiendo por qué. Usé el mismo diseño del Panel con otras imágenes y todo estaba bien. Ahora tiene seis imágenes, pero mucho más grandes en tamaño. no sé si este es el problema y cómo solucionarlo? gracias. Aquí está mi dashboardlayout.Error de StackOverflow, excepción de View.inflate
<com.utils.DashboardLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background" >
<Button
android:id="@+id/home_btn_general_knowledge"
style="@style/DPDashBoardButton"
android:drawableTop="@drawable/general_knowledge_icon_bg_selector"
android:onClick="onGeneralKnowledgeClick"
android:text="General Knowledge" />
<Button
android:id="@+id/home_btn_brainteasers"
style="@style/DPDashBoardButton"
android:drawableTop="@drawable/brain_teasers_icon_bg_selector"
android:onClick="onBrainTeasersClick"
android:text="Brain Teasers" />
<Button
android:id="@+id/home_btn_movies"
style="@style/DPDashBoardButton"
android:drawableTop="@drawable/movies_icon_bg_selector"
android:onClick="onMoviesClick"
android:text="Movies" />
<Button
android:id="@+id/home_btn_sports"
style="@style/DPDashBoardButton"
android:drawableTop="@drawable/sports_icon_bg_selector"
android:onClick="onSportsClick"
android:text="Sports" />
<Button
android:id="@+id/home_btn_music"
style="@style/DPDashBoardButton"
android:drawableTop="@drawable/music_icon_bg_selector"
android:onClick="onMusicClick"
android:text="Music" />
<Button
android:id="@+id/home_btn_celebrities"
style="@style/DPDashBoardButton"
android:drawableTop="@drawable/celebrity_icon_bg_selector"
android:onClick="onCelebritiesClick"
android:text="Celebrities" />
Aquí está el logcat de error:
01-08 02:29:29.216: E/AndroidRuntime(4221): FATAL EXCEPTION: main
01-08 02:29:29.216: E/AndroidRuntime(4221): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hussein.android./com.hussein.android.DashBoardActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class android.widget.Button
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.os.Handler.dispatchMessage(Handler.java:99)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.os.Looper.loop(Looper.java:123)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.ActivityThread.main(ActivityThread.java:3683)
01-08 02:29:29.216: E/AndroidRuntime(4221): at java.lang.reflect.Method.invokeNative(Native Method)
01-08 02:29:29.216: E/AndroidRuntime(4221): at java.lang.reflect.Method.invoke(Method.java:507)
01-08 02:29:29.216: E/AndroidRuntime(4221): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-08 02:29:29.216: E/AndroidRuntime(4221): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-08 02:29:29.216: E/AndroidRuntime(4221): at dalvik.system.NativeStart.main(Native Method)
01-08 02:29:29.216: E/AndroidRuntime(4221): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class android.widget.Button
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
01-08 02:29:29.216: E/AndroidRuntime(4221): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-08 02:29:29.216: E/AndroidRuntime(4221): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.Activity.setContentView(Activity.java:1657)
01-08 02:29:29.216: E/AndroidRuntime(4221): at com.hussein.android.quizgame.DashBoardActivity.onCreate(DashBoardActivity.java:18)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-08 02:29:29.216: E/AndroidRuntime(4221): ... 11 more
01-08 02:29:29.216: E/AndroidRuntime(4221): Caused by: java.lang.reflect.InvocationTargetException
01-08 02:29:29.216: E/AndroidRuntime(4221): at java.lang.reflect.Constructor.constructNative(Native Method)
01-08 02:29:29.216: E/AndroidRuntime(4221): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
01-08 02:29:29.216: E/AndroidRuntime(4221): ... 22 more
01-08 02:29:29.216: E/AndroidRuntime(4221): Caused by: java.lang.StackOverflowError
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable$StateListState.indexOfStateSet(StateListDrawable.java:274)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable$StateListState.access$000(StateListDrawable.java:253)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable.onStateChange(StateListDrawable.java:95)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable.<init>(StateListDrawable.java:306)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable.<init>(StateListDrawable.java:70)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:749)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.content.res.Resources.loadDrawable(Resources.java:1694)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.content.res.Resources.getDrawable(Resources.java:581)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:162)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.content.res.Resources.loadDrawable(Resources.java:1694)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.content.res.Resources.getDrawable(Resources.java:581)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:162)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.content.res.Resources.loadDrawable(Resources.java:1694)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.content.res.Resources.getDrawable(Resources.java:581)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:162)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXml(Dr
01-08 02:29:29.327: D/dalvikvm(4221): GC_CONCURRENT freed 284K, 52% free 2749K/5639K, external 6582K/8020K, paused 7ms+7ms
Aquí i s a una de mis dibujables los sports_icon_bg_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/sports" android:state_focused="true" android:state_pressed="false"/>
<item android:drawable="@drawable/sports" android:state_focused="true" android:state_pressed="true"/>
<item android:drawable="@drawable/sports_blue" android:state_focused="false" android:state_pressed="true"/>
<item android:drawable="@drawable/sports"/>
</selector>
Se puede publicar el contenido de sus dibujables XML? Parece que el error no tiene nada que ver con el diseño del Tablero, pero en el botón de los cuadros (StateListDrawable) –
@MarkRenouf, edité la pregunta según su solicitud. – Hussein