80,351
社区成员
发帖
与我相关
我的任务
分享
public void pointPaint(int rssi){
Resources r = getResources();
//第二个参数就是发光点的源文件
Bitmap bp= BitmapFactory.decodeResource(r, R.drawable.component_radar_light_point);
//int randomNum= (int) (Math.random()*Math.abs(rssi));
//canvas.drawBitmap(bp,x+randomNum,y+randomNum,paint);
customCanvas.drawBitmap(bp, 320, 480, customPaint);
customCanvas.drawBitmap(bp, 240, 130, customPaint);
customCanvas.drawBitmap(bp, 170, 220, customPaint);
customCanvas.drawBitmap(bp, 180, 100, customPaint);
customCanvas.drawBitmap(bp, 460, 400, customPaint);
customCanvas.drawBitmap(bp, 200, 249, customPaint);
customCanvas.drawBitmap(bp, 316, 210, customPaint);
}
customViewByMySelf= (CustomViewByMySelf) findViewById(R.id.customView_DetailDistance);
customViewByMySelf=new CustomViewByMySelf(this,null);
customViewByMySelf.pointPaint(rssi);
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Canvas.drawBitmap(android.graphics.Bitmap, float, float, android.graphics.Paint)' on a null object reference
at tools.CustomViewByMySelf.pointPaint(CustomViewByMySelf.java:138)
at com.example.administrator.bluetoothseekingforproject.DetailDistance.onCreate(DetailDistance.java:51)
at android.app.Activity.performCreate(Activity.java:6147)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2498)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2625)
at android.app.ActivityThread.access$700(ActivityThread.java:183)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1484)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5667)
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:962)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)