大家有人在做百度map的开发吗?哪位高手能帮小弟我看看PopupOverlay这里的showPopup如何了,核心代码和错误已贴上,感激不尽
大家有人在做百度地图的开发吗?谁能帮我看看PopupOverlay这里的showPopup怎么了,核心代码和异常已贴上,感激不尽
在onTap里跑出了空指针异常,不知道为什么
------解决方案--------------------
空指针异常,先花几分钟单步调试找出为空的变量吧。
private MapView mMapView = null;
mPopupView = LayoutInflater.from(BaiduMapActivity.this).inflate(R.layout.pop_layout, null);
public boolean onTap(GeoPoint arg0, MapView arg1) {
// TODO Auto-generated method stub
TextView popText = ((TextView)mPopupView.findViewById(R.id.location_tips));
popText.setText("我的位置: xx省xx市xx区");
pop.showPopup(getBitmapFromView(popText), arg0, 15);
return false;
}
}
//将View转换成Bitmap的方法
public static Bitmap getBitmapFromView(View view) {
view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache();
return bitmap;
}
在onTap里跑出了空指针异常,不知道为什么
------解决方案--------------------
空指针异常,先花几分钟单步调试找出为空的变量吧。