0

我收到 InflatException 的意图有问题。当我单击作为菜单的主活动的任何按钮时,就会发生这种情况。根据日志 Cat 我知道问题应该出在主 Activity 的 xml 上。

我试图压缩更多主 Activity 的图像但没有,所以我想使用 finish(); 调用意图后会释放内存来帮助我解决这个问题,但没有任何想法,任何想法将不胜感激

更新:内存错误出现在inlfating这个布局之后,我试图启动的活动现在是空的,它只有相同的背景,我还没有编程......所以我想是一个罕见的错误

update2:选择器的所有xml文件

主活动的 XML 文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/basegenerica"
    android:orientation="vertical" >

    <Button
        android:id="@+id/twtbtm"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:layout_toLeftOf="@+id/facebtm"
        android:adjustViewBounds="true"
        android:background="@drawable/tww"
        android:clickable="true"
        android:scaleType="fitStart" />

    <Button
        android:id="@+id/facebtm"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_alignParentRight="true"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:adjustViewBounds="true"
        android:background="@drawable/face"
        android:clickable="true"
        android:scaleType="fitStart" />

        <Button
            android:layout_width="fill_parent"
            android:layout_height="110dp"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"
            android:layout_below="@+id/facebtm"
            android:id="@+id/logobancovw"
            android:background="@drawable/logobanco" />

        <Button
            android:id="@+id/beneficiosbtm"
            android:layout_width="fill_parent"
            android:layout_height="37dp"
            android:layout_below="@+id/logobancovw"
            android:layout_marginBottom="6dp"
            android:layout_marginLeft="35dp"
            android:layout_marginRight="35dp"
            android:adjustViewBounds="true"
            android:background="@layout/btnbeneficios"
            android:clickable="true"
            android:scaleType="fitEnd" />

        <Button
            android:id="@+id/consultabtm"
            android:layout_below="@+id/beneficiosbtm"
            android:layout_width="fill_parent"
            android:layout_height="37dp"
            android:layout_marginBottom="6dp"
            android:layout_marginLeft="35dp"
            android:layout_marginRight="35dp"
            android:adjustViewBounds="true"
            android:background="@layout/btnconsulta"
            android:clickable="true"
            android:scaleType="fitEnd" />

        <Button
            android:id="@+id/cajerobtm"
            android:layout_below="@+id/consultabtm"
            android:layout_width="fill_parent"
            android:layout_height="37dp"
            android:layout_marginBottom="6dp"
            android:layout_marginLeft="35dp"
            android:layout_marginRight="35dp"
            android:adjustViewBounds="true"
            android:background="@layout/btncajeros"
            android:clickable="true"
            android:scaleType="fitEnd" />

        <Button
            android:id="@+id/promobtm"
            android:layout_below="@+id/cajerobtm"
            android:layout_width="fill_parent"
            android:layout_height="37dp"
            android:layout_marginBottom="6dp"
            android:layout_marginLeft="35dp"
            android:layout_marginRight="35dp"
            android:adjustViewBounds="true"
            android:background="@layout/btnpromo"
            android:clickable="true"
            android:scaleType="fitStart" />

        <Button
            android:id="@+id/indicadoresbtm"
            android:layout_below="@+id/promobtm"
            android:layout_width="fill_parent"
            android:layout_height="37dp"
            android:layout_marginBottom="6dp"
            android:layout_marginLeft="35dp"
            android:layout_marginRight="35dp"
            android:adjustViewBounds="true"
            android:background="@layout/btnindicadores"
            android:clickable="true"
            android:scaleType="fitEnd" />

        <Button
            android:id="@+id/faqbtm"
            android:layout_below="@+id/indicadoresbtm"
            android:layout_width="fill_parent"
            android:layout_height="37dp"
            android:layout_marginBottom="6dp"
            android:layout_marginLeft="35dp"
            android:layout_marginRight="35dp"
            android:adjustViewBounds="true"
            android:background="@layout/btnfaq"
            android:clickable="true"
            android:scaleType="fitStart" />

        <Button
            android:id="@+id/contactobtm"
            android:layout_below="@+id/faqbtm"
            android:layout_width="fill_parent"
            android:layout_height="37dp"
            android:layout_marginBottom="6dp"
            android:layout_marginLeft="35dp"
            android:layout_marginRight="35dp"
            android:adjustViewBounds="true"
            android:background="@layout/btncontacto"
            android:clickable="true"
            android:scaleType="fitEnd" />

        <Button
            android:id="@+id/soportebtm"
            android:layout_below="@+id/contactobtm"
            android:layout_width="fill_parent"
            android:layout_height="37dp"
            android:layout_marginBottom="6dp"
            android:layout_marginLeft="35dp"
            android:layout_marginRight="35dp"
            android:adjustViewBounds="true"
            android:background="@layout/btnemergencias"
            android:clickable="true"
            android:scaleType="fitEnd" />


</RelativeLayout>

错误的logCat:

05-16 15:53:03.864: D/dalvikvm(804): GC freed 134 objects / 5968 bytes in 51ms
05-16 15:53:04.094: D/dalvikvm(804): GC freed 104 objects / 5248 bytes in 51ms
05-16 15:53:13.714: D/dalvikvm(804): GC freed 315 objects / 19056 bytes in 54ms
05-16 15:53:14.064: E/dalvikvm-heap(804): 4830936-byte external allocation too large for this process.
05-16 15:53:14.064: E/(804): VM won't let us allocate 4830936 bytes
05-16 15:53:14.064: D/AndroidRuntime(804): Shutting down VM
05-16 15:53:14.064: W/dalvikvm(804): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
05-16 15:53:14.074: E/AndroidRuntime(804): Uncaught handler: thread main exiting due to uncaught exception
05-16 15:53:14.094: E/AndroidRuntime(804): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ketanolab.banca.movil/com.ketanolab.banca.movil.soporte}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.os.Looper.loop(Looper.java:123)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.app.ActivityThread.main(ActivityThread.java:4363)
05-16 15:53:14.094: E/AndroidRuntime(804):  at java.lang.reflect.Method.invokeNative(Native Method)
05-16 15:53:14.094: E/AndroidRuntime(804):  at java.lang.reflect.Method.invoke(Method.java:521)
05-16 15:53:14.094: E/AndroidRuntime(804):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
05-16 15:53:14.094: E/AndroidRuntime(804):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
05-16 15:53:14.094: E/AndroidRuntime(804):  at dalvik.system.NativeStart.main(Native Method)
05-16 15:53:14.094: E/AndroidRuntime(804): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.view.LayoutInflater.createView(LayoutInflater.java:513)
05-16 15:53:14.094: E/AndroidRuntime(804):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-16 15:53:14.094: E/AndroidRuntime(804):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.app.Activity.setContentView(Activity.java:1622)
05-16 15:53:14.094: E/AndroidRuntime(804):  at com.ketanolab.banca.movil.soporte.onCreate(soporte.java:29)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
05-16 15:53:14.094: E/AndroidRuntime(804):  ... 11 more
05-16 15:53:14.094: E/AndroidRuntime(804): Caused by: java.lang.reflect.InvocationTargetException
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.widget.LinearLayout.<init>(LinearLayout.java:92)
05-16 15:53:14.094: E/AndroidRuntime(804):  at java.lang.reflect.Constructor.constructNative(Native Method)
05-16 15:53:14.094: E/AndroidRuntime(804):  at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.view.LayoutInflater.createView(LayoutInflater.java:500)
05-16 15:53:14.094: E/AndroidRuntime(804):  ... 21 more
05-16 15:53:14.094: E/AndroidRuntime(804): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.graphics.Bitmap.nativeCreate(Native Method)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.content.res.Resources.loadDrawable(Resources.java:1705)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.view.View.<init>(View.java:1850)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.view.View.<init>(View.java:1799)
05-16 15:53:14.094: E/AndroidRuntime(804):  at android.view.ViewGroup.<init>(ViewGroup.java:284)
05-16 15:53:14.094: E/AndroidRuntime(804):  ... 25 more
05-16 15:53:14.124: I/dalvikvm(804): threadid=7: reacting to signal 3

btncontacto xml 布局文件

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
    android:drawable="@drawable/contacto" />    
<item android:state_pressed="true" 
    android:drawable="@drawable/contactoapre" />
<item android:state_focused="true" android:state_enabled="true"
    android:drawable="@drawable/contacto" />
<item android:state_enabled="true"
    android:drawable="@drawable/contacto" />
</selector>

btnbeneficios XML

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
android:drawable="@drawable/beneficios" />
<item android:state_pressed="true" 
android:drawable="@drawable/beneficiossombra" />
<item android:state_focused="true" android:state_enabled="true"
android:drawable="@drawable/beneficios" />
<item android:state_enabled="true"
android:drawable="@drawable/beneficios" />
</selector>

btcajeros XML

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
    android:drawable="@drawable/loccajeros" />    
<item android:state_pressed="true" 
    android:drawable="@drawable/loccajerosapre" />
<item android:state_focused="true" android:state_enabled="true"
    android:drawable="@drawable/loccajeros" />
<item android:state_enabled="true"
    android:drawable="@drawable/loccajeros" />
</selector>

btnconsulta XML

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
    android:drawable="@drawable/consulta" />    
<item android:state_pressed="true" 
    android:drawable="@drawable/consultaapre" />
<item android:state_focused="true" android:state_enabled="true"
    android:drawable="@drawable/consulta" />
<item android:state_enabled="true"
    android:drawable="@drawable/consulta" />
</selector>

btnemergencias XML

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
    android:drawable="@drawable/emergencia" />    
<item android:state_pressed="true" 
    android:drawable="@drawable/emergenciaapre" />
<item android:state_focused="true" android:state_enabled="true"
    android:drawable="@drawable/emergencia" />
<item android:state_enabled="true"
    android:dr

awable="@drawable/emergencia" />

brnfaq XML

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
    android:drawable="@drawable/tips" />    
<item android:state_pressed="true" 
android:drawable="@drawable/tipssombra" />
<item android:state_focused="true" android:state_enabled="true"
android:drawable="@drawable/tips" />
<item android:state_enabled="true"
android:drawable="@drawable/tips" />
</selector>

btnindicadores XML

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
    android:drawable="@drawable/indicadores" />    
<item android:state_pressed="true" 
    android:drawable="@drawable/indicadoresapre" />
<item android:state_focused="true" android:state_enabled="true"
    android:drawable="@drawable/indicadores" />
<item android:state_enabled="true"
    android:drawable="@drawable/indicadores" />
</selector>

btnpromo XML

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
    android:drawable="@drawable/promociones" />    
<item android:state_pressed="true" 
    android:drawable="@drawable/promocionesapre" />
<item android:state_focused="true" android:state_enabled="true"
    android:drawable="@drawable/promociones" />
<item android:state_enabled="true"
    android:drawable="@drawable/promociones" />
</selector>
4

1 回答 1

2

android:background="@layout/btnconsulta"!!

我假设你想说

android:background="@drawable/btnconsulta"

我知道你不能为背景充气!

如果您希望您的按钮在多个状态下获得不同的样式,请为您的背景或选择器使用颜色或可绘制

按下,专注...

于 2012-05-16T16:14:26.067 回答