【问题标题】:Debug Current Instruction Pointer, trying to add values of three textviews调试当前指令指针,尝试添加三个文本视图的值
【发布时间】:2012-10-03 21:52:53
【问题描述】:

在这里,我尝试添加 3 个文本视图的值,然后使用按钮 onClickListener() 在另一个文本视图中显示,但是每当我单击按钮时,每次获取,不幸的是应用程序在 Logcat 下面停止,请问题并提供一些解决方案, 日志报告

10-13 17:48:40.440: E/Trace(703): error opening trace file: 
No such file or directory (2)
10-13 17:48:41.080: D/dalvikvm(703): 
GC_CONCURRENT freed 65K, 2% free 8362K/8519K,  paused 35ms+30ms, total 214ms
10-13 17:48:41.080: D/gralloc_goldfish(703): Emulator without GPU emulation detected.
10-13 17:49:01.316: I/Choreographer(703): Skipped 31 frames!  
The application may be doing too much work on its main thread.
10-13 17:50:16.511: I/Choreographer(703): Skipped 31 frames!  
The application may be doing too much work on its main thread.
10-13 17:50:35.430: D/AndroidRuntime(703): Shutting down VM
10-13 17:50:35.430: W/dalvikvm(703): threadid=1: 
thread exiting with uncaught exception (group=0x40a13300)
10-13 17:50:35.450: E/AndroidRuntime(703): FATAL EXCEPTION: main
10-13 17:50:35.450: E/AndroidRuntime(703): java.lang.NullPointerException
10-13 17:50:35.450: E/AndroidRuntime(703): 
at com.suvendu.tutorial.cb.CheckBoxTutorialActivity$1.onClick
(CheckBoxTutorialActivity.java:88)
10-13 17:50:35.450: E/AndroidRuntime(703):  
at android.view.View.performClick(View.java:4084)
10-13 17:50:35.450: E/AndroidRuntime(703): 
at android.view.View$PerformClick.run(View.java:16966)
10-13 17:50:35.450: E/AndroidRuntime(703): 
at android.os.Handler.handleCallback(Handler.java:615)
10-13 17:50:35.450: E/AndroidRuntime(703):  
at android.os.Handler.dispatchMessage(Handler.java:92)
10-13 17:50:35.450: E/AndroidRuntime(703):  
at android.os.Looper.loop(Looper.java:137)
10-13 17:50:35.450: E/AndroidRuntime(703):
at android.app.ActivityThread.main(ActivityThread.java:4745)
10-13 17:50:35.450: E/AndroidRuntime(703):
at java.lang.reflect.Method.invokeNative(Native Method)
10-13 17:50:35.450: E/AndroidRuntime(703):   
at java.lang.reflect.Method.invoke(Method.java:511)
10-13 17:50:35.450: E/AndroidRuntime(703):  
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-13 17:50:35.450: E/AndroidRuntime(703):  
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-13 17:50:35.450: E/AndroidRuntime(703):
at dalvik.system.NativeStart.main(Native Method)

活动代码:-

    Integer c;
Integer y;
Integer z;
Integer a;

    btn_total_code=(Button)findViewById(R.id.btn_total);
    btn_total_code.setOnClickListener(new Button.OnClickListener()
   {
   public void onClick (View  v) { 
    c=Integer.parseInt(text_price_regular_code.getText().toString());
    y=Integer.parseInt(text_price_regular_code.getText().toString()); 
    z=Integer.parseInt(text_price_regular_code.getText().toString());   
    a=c+y+z;
    text_total_code.setText(Integer.toString(a)); 
    }

    });

【问题讨论】:

  • 您已经使用 2 个不同的用户 ID 提出了四次这个问题。你不应该只是不断地重复同样的问题。请,请,请仅使用现有的。这相当于垃圾邮件,您正在滥用社区。 stackoverflow.com/users/1736992/user1736992
  • 对不起,西蒙昨天的事件,但朋友我没有得到确切的问题,我真的很喜欢stackoverflow,我相信只有stackoverflow是我可以找到我的每一个答案的地方问题,我知道你会看到我的帖子,并且会明确地评论我,但也想,我没有改变任何值,因为我喜欢实际上,我讨厌假,这里我使用简单的按钮来添加三个值没有别的,如果我将在单独的活动中使用这些代码,那么它可以工作,但是当我在我的完整中使用这几行代码时,我遇到了问题,抱歉。
  • 好的,你保证不会再打开同样的问题,只处理这个问题吗?如果是这样,那我会帮你的。
  • 我的朋友,我也不想创建一个新帐户,但你知道我以前的帐户已被取消,所以我无法联系你说抱歉,感谢你的帮助自然,昨天我以为我对你做错了,我需要亲自向你说声对不起,因为昨天我误用了那种款待,所以我只想忘记以前的谈话,我也请求你请请请请号码有时原谅我,做朋友回答对我来说并不重要,人类高于一切
  • 我们应该把它移到聊天中,因为需要有很多问题...chat.stackoverflow.com/rooms/info/17964/…

标签: android android-emulator android-widget


【解决方案1】:

由于我们无法使用聊天功能,我不知道如何为您提供帮助。对不起。您发布的代码工作正常,我刚刚创建了一个项目。你问的问题不是错误。您只是在 Eclipse 中打了一个断点(我假设您使用的是 Eclipse)。我最好的建议是学习如何使用 Eclispe,尤其是如何调试和如何控制断点。如果不知道如何执行此操作,您将无法成功创建应用程序。

忽略这个:

The application may be doing too much work on its main thread.

这仅仅是因为您在断点处暂停了。这不相关。现在,使用“运行”而不是“调试”来运行您的应用,或者删除断点。

[编辑]

山姆。你需要学习如何捕鱼,而不是要求我每小时给你一条鱼。

学习阅读堆栈跟踪。很简单

10-13 17:50:35.450: E/AndroidRuntime(703): java.lang.NullPointerException
10-13 17:50:35.450: E/AndroidRuntime(703): 
at com.suvendu.tutorial.cb.CheckBoxTutorialActivity$1.onClick
(CheckBoxTutorialActivity.java:88)

在第 88 行的 CheckBoxTutorialActivity 中有一个空指针异常。在该行放置一个断点,运行您的应用程序,看看什么是空的以及为什么。如果您无法弄清楚,请开始一个新问题并为该问题使用准确的标题。

【讨论】:

  • 非常感谢...再次抱歉,很高兴与您交谈,从今天开始,这位 sam 会将您视为老师而不是朋友,对不起老师,我将阅读有关 eclipse 的信息并感谢您建议是因为你是正确的,我使用的是 debug not run,但下次我会尝试运行,希望它会起作用,我保证我不会更改我的 id,也不会问重复的问题.... ...再次cu
  • Simon Sir,我使用了 run 并且还在清单中添加了这一行:- 现在每当点击时我都会收到错误消息获取总计按钮:- 源附件不包含 Integer.class 的源,可能是什么原因...
  • 山姆,很多事情!为什么要添加 ACCESS_NETWORK_STATE?你不需要它来做你正在做的事情。 “源附件”消息只是调试器说您已停止使用 Integer 类的行并且找不到它的源代码。您可能正在尝试使用 Integer 而不是“跳过”来“进入”代码。但是,这与您遇到的任何问题无关。最后,你知道Integer和int的区别吗?您应该大部分时间使用 int,而不是 Integer。
  • simon 先生,我同意你的观点,我已经删除了这两个东西,首先是 ACCESS_NETWORK_STATE,因为在这个程序中我不需要访问网络,其次,我已经将 int 更改为 Integer,但很坦率地说,我之前用错了,先生,请看我的 logcat 报告
  • 当然,先生,我会的……非常感谢,对不起,我占用了您的大量时间,好的先生,但是我从您那里学到了很多与代码、stackoverflow 和对所有人的支持有关的东西。 ...再见
猜你喜欢
  • 2019-07-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-26
相关资源
最近更新 更多