首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

遇到个空指针异常,没有指出异常在哪,求指教。用jxl.jar生成一个GraphicalView,addView()到一个LinearLayout里产生的

2012-05-27 
遇到个空指针错误,没有指出错误在哪,求指教。用jxl.jar生成一个GraphicalView,addView()到一个LinearLayout

遇到个空指针错误,没有指出错误在哪,求指教。用jxl.jar生成一个GraphicalView,addView()到一个LinearLayout里产生的
java.lang.NullPointerException
  at android.graphics.Canvas.throwIfRecycled(Canvas.java:954)
  at android.graphics.Canvas.drawBitmap(Canvas.java:980)
  at org.achartengine.GraphicalView.onDraw(GraphicalView.java:174)
  at android.view.View.draw(View.java:6880)
  at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
  at android.view.View.draw(View.java:6883)
  at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
  at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
  at android.view.View.draw(View.java:6883)
  at android.widget.FrameLayout.draw(FrameLayout.java:357)
  at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
  at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
  at android.view.View.draw(View.java:6883)
  at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
  at android.view.View.draw(View.java:6883)
  at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
  at android.view.View.draw(View.java:6883)
  at android.widget.FrameLayout.draw(FrameLayout.java:357)
  at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
  at android.view.View.draw(View.java:6883)
  at android.widget.FrameLayout.draw(FrameLayout.java:357)
  at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1862)
  at android.view.ViewRoot.draw(ViewRoot.java:1522)
  at android.view.ViewRoot.performTraversals(ViewRoot.java:1258)
  at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:123)
  at android.app.ActivityThread.main(ActivityThread.java:3683)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:507)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  at dalvik.system.NativeStart.main(Native Method)


[解决办法]
这不就是出错位置吗?第174行
at org.achartengine.GraphicalView.onDraw(GraphicalView.java:174)
 
[解决办法]
你通过LinearLayout chartView; 只定义了chartView这个对象类型,但是未看到有实始对像的代码,也就是说chartView是null,你要在onCreate里面再增加一个代码:
chartView = new LinearLayout(getApplicationContext());

热点排行