0

我有 2 个活动“ListmenuActivity”和“SearchmenuActivity”,出于某种奇怪的原因,当我从新打开应用程序,然后打开崩溃的活动(“SearchmenuActivity”)时,它不会崩溃并且可以正常工作。另一方面,当我打开应用程序然后打开包含多个 EditText 的“ListmenuActivity”时,一旦我单击其中一个 EditText,然后打开一个 ListView。当我尝试返回并打开“SearchmenuActivity”时,应用程序在我打开“ListmenuActivity”后崩溃。

我不确定为什么会发生这种情况,如果有人可以提供帮助,将不胜感激。

这是日志:

08-16 11:02:18.928: E/AndroidRuntime(24989): FATAL EXCEPTION: main
08-16 11:02:18.928: E/AndroidRuntime(24989): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.youtube.iamjackpot/com.youtube.iamjackpot.SearchmenuActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2071)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.app.ActivityThread.access$600(ActivityThread.java:138)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.os.Looper.loop(Looper.java:213)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.app.ActivityThread.main(ActivityThread.java:4787)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at java.lang.reflect.Method.invokeNative(Native Method)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at java.lang.reflect.Method.invoke(Method.java:511)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at dalvik.system.NativeStart.main(Native Method)
08-16 11:02:18.928: E/AndroidRuntime(24989): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.view.LayoutInflater.createView(LayoutInflater.java:613)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:262)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.app.Activity.setContentView(Activity.java:1867)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at com.youtube.iamjackpot.SearchmenuActivity.onCreate(SearchmenuActivity.java:13)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.app.Activity.performCreate(Activity.java:5008)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
08-16 11:02:18.928: E/AndroidRuntime(24989):    ... 11 more
08-16 11:02:18.928: E/AndroidRuntime(24989): Caused by: java.lang.reflect.InvocationTargetException
08-16 11:02:18.928: E/AndroidRuntime(24989):    at java.lang.reflect.Constructor.constructNative(Native Method)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.view.LayoutInflater.createView(LayoutInflater.java:587) 
08-16 11:02:18.928: E/AndroidRuntime(24989):    ... 23 more
08-16 11:02:18.928: E/AndroidRuntime(24989): Caused by: java.lang.OutOfMemoryError
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.content.res.Resources.loadDrawable(Resources.java:1935)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.view.View.<init>(View.java:3373)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.view.View.<init>(View.java:3310)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.view.ViewGroup.<init>(ViewGroup.java:454)
08-16 11:02:18.928: E/AndroidRuntime(24989):    at android.widget.RelativeLayout.<init>(RelativeLayout.java:189)
08-16 11:02:18.928: E/AndroidRuntime(24989):    ... 26 more

主要活动我从以下位置打开“SearchmenuActivity”和“ListmenuActivity”:

package com.youtube.iamjackpot;

import android.os.Bundle;
import android.app.Activity;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.widget.ImageButton;
import android.widget.ImageView;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Remove title bar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Search Button:
    ImageView SearchButton = (ImageView) findViewById(R.id.SearchButton);
    SearchButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent searchmenu = new Intent(getApplicationContext(),
                    SearchmenuActivity.class);
            startActivity(searchmenu);

        }
    });
    // List Button
    ImageView ListButton = (ImageView) findViewById(R.id.ListButton);
    ListButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent listmenu = new Intent(getApplicationContext(),
                    ListmenuActivity.class);
            startActivity(listmenu);

        }
    });
    // Popular Button
    ImageView HotButton = (ImageView) findViewById(R.id.HotButton);
    HotButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent popmenu = new Intent(getApplicationContext(),
                    HotmenuActivity.class);
            startActivity(popmenu);
        }
    });
    // Info Button
    ImageView InfoButton = (ImageView) findViewById(R.id.InfoButton);
    InfoButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent infomenu = new Intent(getApplicationContext(),
                    InfomenuActivity.class);
            startActivity(infomenu);
        }
    });
}
}

搜索菜单活动:

package com.youtube.iamjackpot;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;

public class SearchmenuActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_searchmenu);

    String ComponentList[] = {

    "List", "List", "List", "List" };

    AutoCompleteTextView actv = (AutoCompleteTextView) findViewById(R.id.AutoCompleteTextViewSearch);
    actv.setAdapter(new ArrayAdapter<String>(this,
            R.layout.componentlistdetail, ComponentList));

};

}  

列表菜单活动:

package com.youtube.iamjackpot;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class ListmenuActivity extends Activity {

@Override
protected void onCreate(Bundle saveInstanceState) {
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(saveInstanceState);
    setContentView(R.layout.activity_listmenu);

    EditText CPU = (EditText) findViewById(R.id.autoCompleteTextView4);
    CPU.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent CPUList = new Intent(getApplicationContext(),
                    CPUList.class);
            startActivityForResult(CPUList, 1);

        }
    });

    EditText RAMList = (EditText) findViewById(R.id.autoCompleteTextView1);
    RAMList.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            Intent RAMList = new Intent(getApplicationContext(),
                    RAMList.class);
            startActivityForResult(RAMList, 2);

        }
    });

    EditText GPUList = (EditText) findViewById(R.id.autoCompleteTextView3);
    GPUList.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            Intent GPUList = new Intent(getApplicationContext(),
                    GPUList.class);
            startActivityForResult(GPUList, 3);

        }
    });

    EditText MOBOList = (EditText) findViewById(R.id.autoCompleteTextView2);
    MOBOList.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent MOBOList = new Intent(getApplicationContext(),
                    MOBOList.class);
            startActivityForResult(MOBOList, 4);

        }
    });

    EditText CASEList = (EditText) findViewById(R.id.autoCompleteTextView7);
    CASEList.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent CASEList = new Intent(getApplicationContext(),
                    CASEList.class);
            startActivityForResult(CASEList, 5);

        }
    });

    EditText HDDList = (EditText) findViewById(R.id.autoCompleteTextView6);
    HDDList.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            Intent HDDList = new Intent(getApplicationContext(),
                    HDDList.class);
            startActivityForResult(HDDList, 6);
        }
    });

    EditText PSUList = (EditText) findViewById(R.id.autoCompleteTextView9);
    PSUList.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            Intent PSUList = new Intent(getApplicationContext(),
                    PSUList.class);
            startActivityForResult(PSUList, 7);
        }
    });

    EditText SSDList = (EditText) findViewById(R.id.autoCompleteTextView8);
    SSDList.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            Intent SSDList = new Intent(getApplicationContext(),
                    SSDList.class);
            startActivityForResult(SSDList, 8);

        }
    });

    final Button SearchListButton = (Button) findViewById(R.id.SearchListButton);
    SearchListButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {


            Intent OpenDisplayDataActivity = new Intent(
                    ListmenuActivity.this, ListMenuDisplayData.class);
            OpenDisplayDataActivity.putExtra("productCPU",
                    SearchListButton.getText());
            startActivity(OpenDisplayDataActivity);

        }
    });
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_CANCELED) {


    } else if (requestCode == 1) {
        Intent a = getIntent();
        String productCPU = data.getStringExtra("productCPU");
        EditText CPU = ((EditText) findViewById(R.id.autoCompleteTextView4));
        CPU.setText(productCPU);
    } else if (requestCode == 2) {
        // Handle result of RAMList
        Intent b = getIntent();
        String productRAM = data.getStringExtra("productRAM");
        EditText RAM = ((EditText) findViewById(R.id.autoCompleteTextView1));
        RAM.setText(productRAM);
    } else if (requestCode == 3) {
        // handle result of GPU
        Intent c = new Intent();
        String productGPU = data.getStringExtra("productGPU");
        EditText GPU = ((EditText) findViewById(R.id.autoCompleteTextView3));
        GPU.setText(productGPU);
    } else if (requestCode == 4) {
        Intent d = new Intent();
        String productMOBO = data.getStringExtra("productMOBO");
        EditText MOBO = ((EditText) findViewById(R.id.autoCompleteTextView2));
        MOBO.setText(productMOBO);
    } else if (requestCode == 5) {
        Intent e = new Intent();
        String productCASE = data.getStringExtra("productCASE");
        EditText CASE = ((EditText) findViewById(R.id.autoCompleteTextView7));
        CASE.setText(productCASE);
    } else if (requestCode == 6) {

        Intent f = new Intent();
        String productHDD = data.getStringExtra("productHDD");
        EditText HDD = ((EditText) findViewById(R.id.autoCompleteTextView6));
        HDD.setText(productHDD);

    } else if (requestCode == 7) {
        Intent g = new Intent();
        String productPSU = data.getStringExtra("productPSU");
        EditText PSU = ((EditText) findViewById(R.id.autoCompleteTextView9));
        PSU.setText(productPSU);

    } else if (requestCode == 8) {
        Intent h = new Intent();
        String productSSD = data.getStringExtra("productSSD");
        EditText SSD = ((EditText) findViewById(R.id.autoCompleteTextView8));
        SSD.setText(productSSD);

    }

    super.onActivityResult(requestCode, resultCode, data);

}



}
4

1 回答 1

0
package com.youtube.iamjackpot;
import android.os.Bundle;
import android.app.Activity;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.widget.ImageButton;
import android.widget.ImageView;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


ImageView SearchButton = (ImageView) findViewById(R.id.SearchButton);
SearchButton.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {

Intent searchmenu = new Intent(MainActivity.this,
SearchmenuActivity.class);
startActivity(searchmenu);

}
});
于 2013-08-16T10:44:56.350 回答