调用onResume()时出现NullPointerException

时间:2016-06-09 07:36:04

标签: android button nullpointerexception onresume

当我点击按钮更改详细信息时,会发生此崩溃。我能够通过try和catch捕获异常,但我不想掩盖该问题,因为它是NullPointerException。这是我的onResume()活动。例外情况发生在setText()。

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.miairline/com.miairline.chooseflight.FlightDataActivity}: java.lang.NullPointerException
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3196)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3225)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2612)
       at android.app.ActivityThread.access$900(ActivityThread.java:174)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1325)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:146)
       at android.app.ActivityThread.main(ActivityThread.java:5756)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
       at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.NullPointerException
       at com.miairline.chooseflight.FlightDataActivity.onResume(FlightDataActivity.java:551)

这是LOG:

<!doctype html>
<html ng-app="plunker" >
<head>
  <meta charset="utf-8">
  <title>AngularJS Plunker</title>
  <script>document.write('<base href="' + document.location + '" />');</script>
  <link rel="stylesheet" href="style.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js"></script>
  <script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
  <h1> Selected date: {{date2}}</h1>
  <h1> Selected date: {{todate}}</h1>

  <input type="text" ng-model="date2" valueupdate="date2"  datepicker pie-chart-limit-progress-bar="todate" />

  <input type="text" ng-model="todate" datepicker   />

</body>
</html>

0 个答案:

没有答案