当前位置: 首页 > 知识库问答 >
问题:

Android活动错误。点击按钮,“应用程序继续停止”[重复]

高宏峻
2023-03-14

日志猫错误:我不知道这意味着什么,因为我是android新手,请帮助解决这个问题,因为它今晚到期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)

带按钮的菜单页面(沙漠按钮进入沙漠菜单)

  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);
            }
        });


    }
  }

沙漠页面,应该像其他任何东西一样打开,但应用程序停止

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);

    }
}

共有1个答案

潘畅
2023-03-14

您正在使用的图像的实际大小太大,所以请尝试使用一些图像压缩程序对其进行压缩,然后使用。

你也可以在线压缩图像。有很多在线工具可用。

 类似资料:
  • 我在下面写这段代码,这是一个简单的用户注册选项,当我按下创建我的帐户按钮时,我得到:任何人都可以找出原因?我自己想不出来。提前谢谢大家 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 12-28 18:38:57.792 3358-3358/gr.aegean.icsd15109.myfitupE/

  • 我有一个问题,恢复活动的通知点击。我有一个应用程序可以播放一首歌一段时间。这个想法是,当你播放一首歌,并按下Home键时,应该会有一个通知,让你返回到可以停止这首歌的应用程序。 以下是我发出通知的方式: 这是我的舱单:

  • 我的代码首先将我登录到PayPal,然后登录到eBay并导航到“支付费用”页面,然后使用PayPal结账。最后一个“继续”按钮我无法单击/提交。我尝试了xpath、id和类。我甚至尝试发送TAB 7x,直到按下“继续”按钮,然后发送Enter,但没有成功。 我已经找到了这个讨论,但我不知道如何让它为我工作。PayPal沙箱签出“继续按钮”-无法定位元素:-C#网络驱动程序

  • 我想在记录器服务运行时显示通知。用户应该能够在通知中直接暂停或停止记录器。所以我在通知中添加了两个按钮,并实现了一个BroadcastReceiver来处理按钮点击。 它几乎像我想要的那样工作,但有一个问题我无法解决。当用户单击按钮时,我想显示活动。这是我的代码: 目前执行每个按钮的正确操作,但如果用户单击时应用程序不可见,则不显示该应用程序。如何实现这一点? 有必要在这里实现BroadcastR

  • 第二ragment.java jrizal_trivia.java 主要活动。Java语言 这就是错误 错误:(28,31)错误:没有为Intent(, Class)构造函数Intent找到合适的构造函数。Intent(String, Uri)不适用(参数不匹配;无法转换为String)构造函数Intent。Intent(Context, Class)不适用(参数不匹配;无法转换为Context)

  • 每次我点击按钮1,我的应用程序就会崩溃。同一活动中的另一个按钮可以正常工作。我已经试过更换按钮和代码了。控制台中没有错误。