android - FATAL EXCEPTION:main无法启动Activity RunTIme Exception

时间:2013-12-08 08:47:48

标签: android android-intent

这是Log Cat ..

12-08 03:26:01.676: E/AndroidRuntime(1117): FATAL EXCEPTION: main
12-08 03:26:01.676: E/AndroidRuntime(1117): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.blackcat.blackcattourorganizer/com.blackcat.blackcattourorganizer.foodActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.os.Looper.loop(Looper.java:137)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.app.ActivityThread.main(ActivityThread.java:5103)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at java.lang.reflect.Method.invokeNative(Native Method)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at java.lang.reflect.Method.invoke(Method.java:525)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at dalvik.system.NativeStart.main(Native Method)
12-08 03:26:01.676: E/AndroidRuntime(1117): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.view.LayoutInflater.createView(LayoutInflater.java:620)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.app.Activity.setContentView(Activity.java:1895)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at com.blackcat.blackcattourorganizer.foodActivity.onCreate(foodActivity.java:26)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.app.Activity.performCreate(Activity.java:5133)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
12-08 03:26:01.676: E/AndroidRuntime(1117):     ... 11 more
12-08 03:26:01.676: E/AndroidRuntime(1117): Caused by: java.lang.reflect.InvocationTargetException
12-08 03:26:01.676: E/AndroidRuntime(1117):     at java.lang.reflect.Constructor.constructNative(Native Method)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.view.LayoutInflater.createView(LayoutInflater.java:594)
12-08 03:26:01.676: E/AndroidRuntime(1117):     ... 23 more
12-08 03:26:01.676: E/AndroidRuntime(1117): Caused by: java.lang.OutOfMemoryError
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:503)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:356)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:800)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.content.res.Resources.loadDrawable(Resources.java:2105)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.view.View.<init>(View.java:3364)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.view.ViewGroup.<init>(ViewGroup.java:459)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.widget.LinearLayout.<init>(LinearLayout.java:176)
12-08 03:26:01.676: E/AndroidRuntime(1117):     at android.widget.LinearLayout.<init>(LinearLayout.java:172)
12-08 03:26:01.676: E/AndroidRuntime(1117):     ... 26 more

好的所以这是下面的活动:

@Override
protected void onCreate(Bundle foodActivityState) {
    super.onCreate(foodActivityState);
    setContentView(R.layout.food_activity);

    backgroundimage = (View) findViewById(R.id.food_background);
    background = backgroundimage.getBackground();
    //background.setAlpha(50);

    editText_foodActivity = (EditText) findViewById(R.id.editText_foodActivity);
    editText_foodActivity.setInputType(InputType.TYPE_CLASS_NUMBER);

    done = (Button) findViewById(R.id.button1_foodActivity);
    done.setOnClickListener(this);
    back = (Button) findViewById(R.id.button2_foodActivity);
    back.setOnClickListener(this);
}

@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.button1_foodActivity:
            boolean didItWork = true;

            tourDB gettingInfo = new tourDB(this);

            gettingInfo.open();

            long getlastID = gettingInfo.getMaxID();

            int prev_food = gettingInfo.getFoodPrev(getlastID);

            String getAmountString = editText_foodActivity.getText().toString();

            int getAmountInt = Integer.parseInt(getAmountString);

            prev_food = prev_food + getAmountInt;

            int prev_remainbudget = gettingInfo.getPrevRemainBudget(getlastID);

            prev_remainbudget = prev_remainbudget - getAmountInt;

            try{

                gettingInfo.updatePrevRemainBudget(getlastID, prev_remainbudget);

                gettingInfo.updatefoodEntry(getlastID, prev_food);

                gettingInfo.close();

            }catch(Exception e){
                didItWork = false;
                String error = e.toString();
                Dialog d = new Dialog(this);
                d.setTitle("Not Updated");
                TextView tv = new TextView(this);
                tv.setText(error);
                d.setContentView(tv);
                d.show();
            } finally {
                if (didItWork) {
                    Dialog d = new Dialog(this);
                    d.setTitle("Data Updated");
                    d.show();
                }

                Intent openonGoingActivity = new Intent("com.blackcat.blackcattourorganizer.ONGOINGACTIVITY");
                startActivity(openonGoingActivity);
            }
            break;

        case R.id.button2_foodActivity:

            Intent openonGoingActivity = new Intent("com.blackcat.blackcattourorganizer.ONGOINGACTIVITY");
            startActivity(openonGoingActivity);

            break;
    }
}

}

现在给出了xml文件:

<EditText
    android:id="@+id/editText_foodActivity"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="50dp"
    android:hint="@string/edit_expence">

</EditText>

<Button
    android:id="@+id/button1_foodActivity"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="50dp"
    android:text="@string/done_expense"/>

<Button
    android:id="@+id/button2_foodActivity"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="50dp"
    android:text="@string/back_expense"/>

为什么意图不起作用?

0 个答案:

没有答案