奇怪的Android.view.InflateException

时间:2012-10-05 14:06:16

标签: android layout

您好我开发了一个小应用程序,它包含一个仪表板,可以将您发送到一些不同的简单屏幕。我面临一个奇怪的问题,我打开仪表板上的应用程序,我选择一个随机屏幕进行投射。按回选择第二个随机选项,如“联系我们”,在第三个选项中,无论我经历的菜单按钮顺序如何,它总是会崩溃。

dashBoard.java类就像10个按钮一样简单,它们各自的意图会将您发送到其他基本屏幕。

dashboard.java如下:

public class DashBoardActivity extends Activity implements View.OnClickListener{
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        Button soportebt, beneficiosbt, faqbt, twtbt, facebt;
        Button contactobt;
        Button cajerosbt;
        Button consultacuentabt;
        Button indicadoresfinancierosbt;
        Button promocionesbt;
        setContentView(R.layout.mainmenu);

        //inicializar variables de botones
        faqbt = (Button) findViewById(R.id.faqbtm);
        facebt = (Button) findViewById(R.id.twtbtm);
        beneficiosbt = (Button) findViewById(R.id.beneficiosbtm);
        twtbt = (Button) findViewById(R.id.facebtm);
        soportebt = (Button) findViewById(R.id.soportebtm);
        contactobt = (Button) findViewById(R.id.contactobtm);
        cajerosbt = (Button) findViewById(R.id.cajerobtm);
        consultacuentabt = (Button) findViewById(R.id.consultabtm);
        indicadoresfinancierosbt = (Button) findViewById(R.id.indicadoresbtm);
        promocionesbt = (Button) findViewById(R.id.promobtm);

        //click de las variables
        faqbt.setOnClickListener(this);
        beneficiosbt.setOnClickListener(this);
        facebt.setOnClickListener(this);
        twtbt.setOnClickListener(this);
        soportebt.setOnClickListener(this);
        contactobt.setOnClickListener(this);
        promocionesbt.setOnClickListener(this);
        cajerosbt.setOnClickListener(this);
        consultacuentabt.setOnClickListener(this);
        indicadoresfinancierosbt.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch(v.getId()){
        case R.id.faqbtm:
            Intent intent = new Intent(getApplicationContext(), FAQ.class);
            startActivity(intent);      
            break;
        case R.id.facebtm:
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/KetanoLab") ) );
            break;
        case R.id.twtbtm:
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/#!/KetanoLab") ) );
            break;
        case R.id.soportebtm:
            Intent intent3 = new Intent(getApplicationContext(), soporte.class);
            startActivity(intent3);
            break;
        case R.id.consultabtm:
            Intent intent7 = new Intent(getApplicationContext(), consultacuenta.class);
            startActivity(intent7);
            break;
        case R.id.beneficiosbtm:
            Intent intent2 = new Intent(getApplicationContext(), beneficios.class);
            startActivity(intent2); 
            break;
        case R.id.contactobtm:
            Intent intent4 = new Intent(getApplicationContext(), contacto.class);
            startActivity(intent4); 
            break;
        case R.id.cajerobtm:
            Intent intent6 = new Intent(getApplicationContext(), cajeros.class);
            startActivity(intent6);
            break;
        case R.id.indicadoresbtm:
            Intent intent8 = new Intent(getApplicationContext(), indicadoresFinancieros.class);
            startActivity(intent8);
            break;
        case R.id.promobtm:
            Intent intent5 = new Intent(getApplicationContext(), promo.class);
            startActivity(intent5);
            break;

        }

    }
}

布局mainmenu.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"
    android:background="@drawable/bacoprin"
    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:id="@+id/faqbtm"
        android:layout_width="175dp"
        android:layout_height="50dp"
        android:layout_above="@+id/promobtm"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="12dp"
        android:adjustViewBounds="true"
        android:background="@drawable/btnfaq"
        android:clickable="true"
        android:scaleType="fitStart" />

    <Button
        android:id="@+id/promobtm"
        android:layout_width="175dp"
        android:layout_height="50dp"
        android:layout_above="@+id/indicadoresbtm"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="12dp"
        android:adjustViewBounds="true"
        android:background="@drawable/btnpromo"
        android:clickable="true"
        android:scaleType="fitStart" />

    <Button
        android:id="@+id/beneficiosbtm"
        android:layout_width="175dp"
        android:layout_height="50dp"
        android:layout_above="@+id/consultabtm"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="12dp"
        android:adjustViewBounds="true"
        android:background="@drawable/btnbeneficios"
        android:clickable="true"
        android:scaleType="fitEnd" />

    <Button
        android:id="@+id/consultabtm"
        android:layout_width="175dp"
        android:layout_height="50dp"
        android:layout_above="@+id/cajerobtm"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="12dp"
        android:adjustViewBounds="true"
        android:background="@drawable/btnconsulta"
        android:clickable="true"
        android:scaleType="fitEnd" />

    <Button
        android:id="@+id/indicadoresbtm"
        android:layout_width="175dp"
        android:layout_height="50dp"
        android:layout_above="@+id/contactobtm"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="12dp"
        android:adjustViewBounds="true"
        android:background="@drawable/btnindicadores"
        android:clickable="true"
        android:scaleType="fitEnd" />

    <Button
        android:id="@+id/cajerobtm"
        android:layout_width="175dp"
        android:layout_height="50dp"
        android:layout_above="@+id/contactobtm"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="12dp"
        android:adjustViewBounds="true"
        android:background="@drawable/btncajeros"
        android:clickable="true"
        android:scaleType="fitEnd" />

    <Button
        android:id="@+id/contactobtm"
        android:layout_width="175dp"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="25dp"
        android:adjustViewBounds="true"
        android:background="@drawable/btncontacto"
        android:clickable="true"
        android:scaleType="fitEnd" />

    <Button
        android:id="@+id/soportebtm"
        android:layout_width="175dp"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="25dp"
        android:adjustViewBounds="true"
        android:background="@drawable/btnemergencias"
        android:clickable="true"
        android:scaleType="fitEnd" />

</RelativeLayout>

dasboard上的每个可绘制按钮都具有以下结构:

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>

显示问题的logCat

10-05 10:01:29.490: D/ViewRootImpl(2621): Action[0] ID[0] Pos[105.92644,783.9985]
10-05 10:01:29.550: D/ViewRootImpl(2621): Action[1] ID[0] Pos[99.9306,794.9942]
10-05 10:02:02.100: I/dalvikvm-heap(2866): Grow heap (frag case) to 17.717MB for 3075856-byte allocation
10-05 10:02:02.170: D/dalvikvm(2866): GC_CONCURRENT freed 88K, 7% free 15725K/16811K, paused 4ms+2ms
10-05 10:02:02.230: I/dalvikvm-heap(2866): Grow heap (frag case) to 32.480MB for 12303376-byte allocation
10-05 10:02:02.270: D/dalvikvm(2866): GC_CONCURRENT freed <1K, 4% free 27739K/28847K, paused 5ms+2ms
10-05 10:02:02.500: I/dalvikvm-heap(2866): Grow heap (frag case) to 39.008MB for 309040-byte allocation
10-05 10:02:02.540: D/dalvikvm(2866): GC_CONCURRENT freed 4008K, 14% free 29130K/33711K, paused 2ms+2ms
10-05 10:02:18.010: D/ViewRootImpl(2866): Action[0] ID[0] Pos[151.39487,858.96924]
10-05 10:02:18.090: D/ViewRootImpl(2866): Action[1] ID[0] Pos[153.89313,865.4667]
10-05 10:02:19.050: D/ViewRootImpl(2866): Action[0] ID[0] Pos[181.37404,771.0036]
10-05 10:02:19.140: D/ViewRootImpl(2866): Action[1] ID[0] Pos[183.37265,777.0012]
10-05 10:02:19.190: I/dalvikvm-heap(2866): Grow heap (frag case) to 41.742MB for 4292480-byte allocation
10-05 10:02:19.240: D/dalvikvm(2866): GC_CONCURRENT freed 396K, 10% free 34488K/37935K, paused 2ms+2ms
10-05 10:02:19.260: I/dalvikvm-heap(2866): Grow heap (frag case) to 48.628MB for 7627300-byte allocation
10-05 10:02:19.300: D/dalvikvm(2866): GC_CONCURRENT freed 3K, 8% free 41933K/45423K, paused 2ms+3ms
10-05 10:02:21.080: D/ViewRootImpl(2866): Action[0] ID[0] Pos[223.84454,932.9403]
10-05 10:02:21.180: D/ViewRootImpl(2866): Action[1] ID[0] Pos[222.3456,937.43854]
10-05 10:02:21.300: I/dalvikvm-heap(2866): Grow heap (frag case) to 54.425MB for 3075856-byte allocation
10-05 10:02:21.360: I/dalvikvm-heap(2866): Clamp target GC heap from 66.160MB to 64.000MB
10-05 10:02:21.360: I/dalvikvm-heap(2866): Grow heap (frag case) to 64.000MB for 12303376-byte allocation
10-05 10:02:21.380: D/dalvikvm(2866): GC_CONCURRENT freed 4786K, 13% free 55102K/62767K, paused 2ms+4ms
10-05 10:02:22.650: D/ViewRootImpl(2866): Action[0] ID[0] Pos[199.8612,1071.8861]
10-05 10:02:22.720: D/ViewRootImpl(2866): Action[1] ID[0] Pos[199.36156,1073.3855]
10-05 10:02:22.840: I/dalvikvm-heap(2866): Forcing collection of SoftReferences for 12303376-byte allocation
10-05 10:02:22.860: D/dalvikvm(2866): GC_BEFORE_OOM freed 12808K, 28% free 45325K/62767K, paused 21ms
10-05 10:02:22.900: D/dalvikvm(2866): GC_CONCURRENT freed 12029K, 28% free 45311K/62767K, paused 2ms+3ms
10-05 10:02:24.370: D/ViewRootImpl(2866): Action[0] ID[0] Pos[204.35808,1217.3293]
10-05 10:02:24.480: D/ViewRootImpl(2866): Action[1] ID[0] Pos[208.3553,1217.3293]
10-05 10:02:24.610: I/dalvikvm-heap(2866): Forcing collection of SoftReferences for 12303376-byte allocation
10-05 10:02:24.640: D/dalvikvm(2866): GC_BEFORE_OOM freed 3021K, 28% free 45357K/62767K, paused 23ms
10-05 10:02:24.640: E/dalvikvm-heap(2866): Out of memory on a 12303376-byte allocation.
10-05 10:02:24.640: I/dalvikvm(2866): "main" prio=5 tid=1 RUNNABLE
10-05 10:02:24.640: I/dalvikvm(2866):   | group="main" sCount=0 dsCount=0 obj=0x40c0f460 self=0x1e0fa58
10-05 10:02:24.640: I/dalvikvm(2866):   | sysTid=2866 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1074357512
10-05 10:02:24.640: I/dalvikvm(2866):   | schedstat=( 2316137000 607448000 1407 ) utm=205 stm=26 core=0
10-05 10:02:24.640: I/dalvikvm(2866):   at android.graphics.Bitmap.nativeCreate(Native Method)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.content.res.Resources.loadDrawable(Resources.java:1937)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.view.View.<init>(View.java:2798)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.view.ViewGroup.<init>(ViewGroup.java:385)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.widget.LinearLayout.<init>(LinearLayout.java:174)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.widget.LinearLayout.<init>(LinearLayout.java:170)
10-05 10:02:24.640: I/dalvikvm(2866):   at java.lang.reflect.Constructor.constructNative(Native Method)
10-05 10:02:24.640: I/dalvikvm(2866):   at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.view.LayoutInflater.createView(LayoutInflater.java:586)
10-05 10:02:24.640: I/dalvikvm(2866):   at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
10-05 10:02:24.640: I/dalvikvm(2866):   at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:252)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.app.Activity.setContentView(Activity.java:1888)
10-05 10:02:24.640: I/dalvikvm(2866):   at com.ketanolab.banca.movil.generico.soporte.onCreate(soporte.java:32)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.app.Activity.performCreate(Activity.java:4518)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1924)
10-05 10:02:24.640: I/dalvikvm(2866):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1985)
10-05 10:02:24.650: I/dalvikvm(2866):   at android.app.ActivityThread.access$600(ActivityThread.java:127)
10-05 10:02:24.650: I/dalvikvm(2866):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1151)
10-05 10:02:24.650: I/dalvikvm(2866):   at android.os.Handler.dispatchMessage(Handler.java:99)
10-05 10:02:24.650: I/dalvikvm(2866):   at android.os.Looper.loop(Looper.java:137)
10-05 10:02:24.650: I/dalvikvm(2866):   at android.app.ActivityThread.main(ActivityThread.java:4493)
10-05 10:02:24.650: I/dalvikvm(2866):   at java.lang.reflect.Method.invokeNative(Native Method)
10-05 10:02:24.650: I/dalvikvm(2866):   at java.lang.reflect.Method.invoke(Method.java:511)
10-05 10:02:24.650: I/dalvikvm(2866):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
10-05 10:02:24.650: I/dalvikvm(2866):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
10-05 10:02:24.650: I/dalvikvm(2866):   at dalvik.system.NativeStart.main(Native Method)
10-05 10:02:24.650: D/AndroidRuntime(2866): Shutting down VM
10-05 10:02:24.650: W/dalvikvm(2866): threadid=1: thread exiting with uncaught exception (group=0x40c0e1f8)
10-05 10:02:24.660: E/AndroidRuntime(2866): FATAL EXCEPTION: main
10-05 10:02:24.660: E/AndroidRuntime(2866): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ketanolab.banca.movil.generico/com.ketanolab.banca.movil.generico.soporte}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1960)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1985)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.app.ActivityThread.access$600(ActivityThread.java:127)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1151)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.os.Looper.loop(Looper.java:137)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.app.ActivityThread.main(ActivityThread.java:4493)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at java.lang.reflect.Method.invokeNative(Native Method)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at java.lang.reflect.Method.invoke(Method.java:511)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at dalvik.system.NativeStart.main(Native Method)
10-05 10:02:24.660: E/AndroidRuntime(2866): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.view.LayoutInflater.createView(LayoutInflater.java:606)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:252)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.app.Activity.setContentView(Activity.java:1888)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at com.ketanolab.banca.movil.generico.soporte.onCreate(soporte.java:32)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.app.Activity.performCreate(Activity.java:4518)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1924)
10-05 10:02:24.660: E/AndroidRuntime(2866):     ... 11 more
10-05 10:02:24.660: E/AndroidRuntime(2866): Caused by: java.lang.reflect.InvocationTargetException
10-05 10:02:24.660: E/AndroidRuntime(2866):     at java.lang.reflect.Constructor.constructNative(Native Method)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.view.LayoutInflater.createView(LayoutInflater.java:586)
10-05 10:02:24.660: E/AndroidRuntime(2866):     ... 23 more
10-05 10:02:24.660: E/AndroidRuntime(2866): Caused by: java.lang.OutOfMemoryError
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.graphics.Bitmap.nativeCreate(Native Method)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.content.res.Resources.loadDrawable(Resources.java:1937)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.view.View.<init>(View.java:2798)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.view.ViewGroup.<init>(ViewGroup.java:385)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.widget.LinearLayout.<init>(LinearLayout.java:174)
10-05 10:02:24.660: E/AndroidRuntime(2866):     at android.widget.LinearLayout.<init>(LinearLayout.java:170)
10-05 10:02:24.660: E/AndroidRuntime(2866):     ... 26 more

注意:对于图像:每个视图背景图像为40kb,按钮的两个图像中的每一个都是9kb大小。

奇怪的是,如果你看一下logcat,那就是崩溃之前分配的内存会成倍增长。另外一个奇怪的想法是,我的lg 4x HD上有1gb ram比使用cm7.1端口的旧x10 mini更快崩溃。

关于如何解决这个问题的任何想法将不胜感激!

Edit1:使用DDMS堆更新我看到,除了屏幕之外,还有更少的45.000个对象。所以我猜是一个堆问题

编辑:对于那些想要查看支持类xml文件的人来说:

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

    <Button
        android:id="@+id/lostcardbtn"
        android:layout_width="270dp"
        android:layout_height="58dp"
        android:layout_marginLeft="45dp"
        android:layout_marginRight="45dp"
        android:layout_marginTop="130dp"
        android:background="@layout/btnstandar"
        android:text="@string/emergencia_lostcardbtn_txt"
        android:textStyle="bold"
        android:typeface="serif" />

    <Button
        android:id="@+id/callpolicebtn"
               android:layout_width="270dp"
        android:layout_height="58dp"
        android:layout_marginLeft="45dp"
        android:layout_marginRight="45dp"
        android:layout_marginTop="17dp"
        android:background="@layout/btnstandar"
        android:text="@string/emergencia_callpolicebtn_txt"
        android:textStyle="bold"
        android:typeface="serif" />

    <Button
        android:id="@+id/callhospitalbtn"
               android:layout_width="270dp"
        android:layout_height="58dp"
        android:layout_marginLeft="45dp"
        android:layout_marginRight="45dp"
        android:layout_marginTop="17dp"
        android:background="@layout/btnstandar"
        android:text="@string/emergencia_callhospitalbtn_txt"
        android:textStyle="bold"
        android:typeface="serif" />

</LinearLayout>

0 个答案:

没有答案