2

The log cat error: I have no idea what this means as I am new to android please help fix this as its due tonight LOL :(

01-09 13:34:55.608 6929-6929/com.example.james.assignment1_18094969 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.james.assignment1_18094969, PID: 6929
java.lang.RuntimeException: Canvas: trying to draw too large(121480800bytes) bitmap.
    at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:260)
    at android.graphics.Canvas.drawBitmap(Canvas.java:1415)
    at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:528)
    at android.widget.ImageView.onDraw(ImageView.java:1316)
    at android.view.View.draw(View.java:17185)
    at android.view.View.updateDisplayListIfDirty(View.java:16167)
    at android.view.View.draw(View.java:16951)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
    at android.view.View.draw(View.java:17188)
    at android.view.View.updateDisplayListIfDirty(View.java:16167)
    at android.view.View.draw(View.java:16951)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
    at android.view.View.updateDisplayListIfDirty(View.java:16162)
    at android.view.View.draw(View.java:16951)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
    at android.view.View.updateDisplayListIfDirty(View.java:16162)
    at android.view.View.draw(View.java:16951)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
    at android.view.View.updateDisplayListIfDirty(View.java:16162)
    at android.view.View.draw(View.java:16951)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
    at android.view.View.updateDisplayListIfDirty(View.java:16162)
    at android.view.View.draw(View.java:16951)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
    at android.view.View.draw(View.java:17188)
    at com.android.internal.policy.DecorView.draw(DecorView.java:753)
    at android.view.View.updateDisplayListIfDirty(View.java:16167)
    at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:648)
    at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:654)
    at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:762)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:2800)
    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2608)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2215)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
    at android.view.Choreographer.doCallbacks(Choreographer.java:686)
    at android.view.Choreographer.doFrame(Choreographer.java:621)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Menu page with button (Desert button to take to desert menu)

  package com.example.james.assignment1_18094969;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Menu extends AppCompatActivity {

    //takes user to the pizza menu
    Button PizzaMenu;
    //return to home
    Button back;
    //takes user to the drinks menu
    Button drinksMenu;
    //takes user to the sides menu
    Button sidesMenu;
    //takes user to the desert menu
    Button desertsMenu;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_menu);

    PizzaMenu = (Button) findViewById(R.id.button_Pizza);
        PizzaMenu.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Menu.this, Pizzas.class);
                startActivity(intent);
            }
        });

    back = (Button) findViewById(R.id.menu_2home);
        back.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent (Menu.this, Home.class);
                startActivity(intent);
            }
        });

     drinksMenu = (Button) findViewById(R.id.button_Drinks);
        drinksMenu.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Menu.this, Drinks.class);
                startActivity(intent);
            }
        });

     sidesMenu = (Button) findViewById(R.id.button_sides);
        sidesMenu.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Menu.this, Sides.class);
                startActivity(intent);
            }
        });

     desertsMenu = (Button) findViewById(R.id.button_Desert);
        desertsMenu.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Menu.this, Deserts.class);
                startActivity(intent);
            }
        });


    }
  }

Desert Page that should open like everything else does but application stops

package com.example.james.assignment1_18094969;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;

import java.util.ArrayList;

public class Deserts extends AppCompatActivity {

    Button submit;
    Button cancel;
    TextView message;
    ArrayList<String> selection = new ArrayList<String>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_deserts);

        message = (TextView) findViewById(R.id.textView_deserts);
        message.setEnabled(false);
    //cancel button takes user out of the desert screen to the main menu
        cancel = (Button) findViewById(R.id.button_desertCancel);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Deserts.this, Menu.class);
                startActivity(intent);
            }
        });

    //submit button takes the user back to the menu after selecting their desert(s)
        submit = (Button) findViewById(R.id.button_desertSubmit);
        submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Deserts.this, Menu.class);
            }
        });

    }

    //case checks for the selected check boxes and adds it to the string array
    public void SelectDesertItem(View view) {
        boolean checked = ((CheckBox) view).isChecked();
        switch (view.getId()) {
            case R.id.checkBox_Gelato:

                if (checked) {
                    selection.add("Gelato");
                } else {
                    selection.remove("Gelato");
                }
                break;

            case R.id.checkBox_chocFudge:

                if (checked) {
                    selection.add("Chocolate Fudge");
                } else {
                    selection.remove("Chocolate Fudge");
                }
                break;

            case R.id.checkbox_cheeseCake:

                if (checked) {
                    selection.add("Cheese Cake");
                } else {
                    selection.remove("Cheese Cake");
                }
                break;


        }
    }

    //defines the display message "you have selected" and adds the options selected from the string array list.

    public void finalDesertSelect(View view){
        String finalDesertSelect ="";

        for (String Selections : selection)
        {
            finalDesertSelect = finalDesertSelect + Selections + "\n";
        }

        message.setText("You have selected:" + "\n" + finalDesertSelect);
        message.setEnabled(true);

    }
}
Isaac
  • 1,442
  • 17
  • 26
james.d_12
  • 57
  • 8

1 Answers1

2

The actual size of the image you are using is too large, so try some image compressor to compress it and then use.

You can compress your images online also. As many online tools are available.

Kanwaljit Singh
  • 4,339
  • 2
  • 18
  • 21