编译无报错,但运行时Message类msg.what处抛NotFoundException

主要报错:

        对于语句:

          textView.setText(msg.what);

    报错android.content.res.Resources$NotFoundException: String resource ID #0x1

  ********************

原因:没有对msg.what进行String类型转换

解决方法:

          textView.setText(String.valueOf(msg.what));

  **********************

完整报错:

E/AndroidRuntime: FATAL EXCEPTION: main
                                                             Process: com.ceil.rpedometer, PID: 29074
                                                             android.content.res.Resources$NotFoundException: String resource ID #0x1
                                                             at android.content.res.Resources.getText(Resources.java:341)
                                                             at android.widget.TextView.setText(TextView.java:4214)
                           at com.ceil.rpedometer.calculate.activity.CalculateImpl$1.handleMessage(CalculateImpl.java:42)
                                                             at android.os.Handler.dispatchMessage(Handler.java:111)
                                                             at android.os.Looper.loop(Looper.java:194)
                                                             at android.app.ActivityThread.main(ActivityThread.java:5796)
                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                             at java.lang.reflect.Method.invoke(Method.java:372)
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1010)
                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)

猜你喜欢

转载自blog.csdn.net/qq_39587209/article/details/79872967