在我的应用程序中很少不总是,在缩放护目镜地图时出现nullpointer异常 我已经把检查条件但问题仍然存在请任何人帮助我stacktrace是: -
06-25 20:02:31.207: W/System.err(10102): java.lang.NullPointerException
06-25 20:02:31.207: W/System.err(10102): at com.google.android.maps.ItemizedOverlay.populate(ItemizedOverlay.java:312)
06-25 20:02:31.207: W/System.err(10102): at com.rentfaster.home.GoogleMapView$GoogleMapViewOverlay.addItem(GoogleMapView.java:1668)
06-25 20:02:31.211: W/System.err(10102): at com.rentfaster.home.GoogleMapView$Mapdatatask.onPostExecute(GoogleMapView.java:1417)
06-25 20:02:31.211: W/System.err(10102): at com.rentfaster.home.GoogleMapView$Mapdatatask.onPostExecute(GoogleMapView.java:1)
06-25 20:02:31.215: W/System.err(10102): at android.os.AsyncTask.finish(AsyncTask.java:602)
06-25 20:02:31.218: W/System.err(10102): at android.os.AsyncTask.access$600(AsyncTask.java:156)
06-25 20:02:31.218: W/System.err(10102): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)
06-25 20:02:31.218: W/System.err(10102): at android.os.Handler.dispatchMessage(Handler.java:99)
06-25 20:02:31.222: W/System.err(10102): at android.os.Looper.loop(Looper.java:137)
06-25 20:02:31.222: W/System.err(10102): at android.app.ActivityThread.main(ActivityThread.java:4424)
06-25 20:02:31.222: W/System.err(10102): at java.lang.reflect.Method.invokeNative(Native Method)
06-25 20:02:31.226: W/System.err(10102): at java.lang.reflect.Method.invoke(Method.java:511)
06-25 20:02:31.226: W/System.err(10102): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-25 20:02:31.226: W/System.err(10102): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-25 20:02:31.230: W/System.err(10102): at dalvik.system.NativeStart.main(Native Method)
这个问题每次都没有出现这就是我无法找到错误的原因请任何人看到我的代码并建议我: -
@Override
protected void onPostExecute(Integer result)
{
if(!valueoftotal.equalsIgnoreCase("") && !valueoftotal.equalsIgnoreCase(null))
{
if(Integer.parseInt(valueoftotal) > 0 && Integer.parseInt(valueoftotal) <= 100)
{
OverlayItem oi;
if(myHandler.getParsedData()!=null)
{
arrayList = myHandler.getParsedData();
}
linearbottom2.setClickable(true);
mapOverlays.clear();
overlay.removeAll();
lineartabbar.setBackgroundResource(R.drawable.mapbar);
if(arrayList.size()!=0 && arrayList.size()>1 )
{
for(int i = 0; i < arrayList.size(); i++) {
String latvalue = arrayList.get(i).getLatitude().toString();
String lonvalue = arrayList.get(i).getLongitude().toString();
GeoPoint point = null;
try
{
point = new GeoPoint((int)(Double.parseDouble(latvalue)*1E6),(int)(Double.parseDouble(lonvalue)*1E6));
}
catch (NumberFormatException e)
{
}
if(point != null)
{
if(arrayList.get(i).getUnitstotal().equalsIgnoreCase("1"))
{
oi = overlay.createItem(i);
if(overlay!=null && oi!=null)
{
overlay.addItem(oi);
}
}
else if(!arrayList.get(i).getUnitstotal().equalsIgnoreCase("1"))
{
oi = overlay.createItem(i);
if(overlay!=null && oi!=null)
{
overlay.addItem(oi);
}
}
}
}
mapOverlays.add(overlay);
mapView.invalidate();
}
else if( arrayList.size()!=0 && arrayList.size()==1 )
{
for(int i = 0; i < arrayList.size(); i++) {
String latvalue = arrayList.get(i).getLatitude().toString();
String lonvalue = arrayList.get(i).getLongitude().toString();
GeoPoint point = null;
try
{
point = new GeoPoint((int)(Double.parseDouble(latvalue)*1E6),(int)(Double.parseDouble(lonvalue)*1E6));
}
catch (NumberFormatException e) {
// TODO: handle exception
}
if(point != null)
{
if(arrayList.get(i).getUnitstotal().equalsIgnoreCase("1"))
{
oi = overlay.createItem(i);
System.out.println("listing when 1 value is "+arrayList.get(i).getUnitstotal());
overlay.addItem(oi);
mc.animateTo(point);
mc.setCenter(point);
mc.setZoom(16);
}
else if(!arrayList.get(i).getUnitstotal().equalsIgnoreCase("1"))
{
oi = overlay.createItem(i);
System.out.println("listing when more value is "+ arrayList.get(i).getUnitstotal());
overlay.addItem(oi);
mc.animateTo(point);
mc.setCenter(point);
mc.setZoom(12);
}
}
}
mapOverlays.add(overlay);
mapView.invalidate();
MapController mcontrller =mapView.getController();
/*mcontrller.animateTo(arg0)
mcontrller.setCenter();
mcontrller.setZoom(zoomLevel);
*/
}
textViewpopup.setText(valueoftotal+" listings found.");
linearlayoutpopup.setVisibility(View.VISIBLE);
RunAnimationslisting();
}
else if(Integer.parseInt(valueoftotal) > 100)
{
Eyelidmessage(valueoftotal+" listings found. \n Zoom-in, press the locate button below or select the refine button above to display fewer properties. ");
lineartabbar.setBackgroundResource(R.drawable.mapwithoutlist);
linearbottom2.setClickable(false);
}
else if(Integer.parseInt(valueoftotal) == 0)
{
GoneAnimations();
lineartabbar.setBackgroundResource(R.drawable.mapwithoutlist);
linearbottom2.setClickable(false);
customizeDialog = new CustomizeDialog(activity);
customizeDialog.setTitle("Sorry");
customizeDialog.setMessage("No Listing Found");
customizeDialog.show();
}
}
super.onPostExecute(result);
}
对不起我的解释。
答案 0 :(得分:1)
而不是写
protected void onPostExecute(Integer result)
{
if(!valueoftotal.equalsIgnoreCase("") && !valueoftotal.equalsIgnoreCase(null))
{
}
}
试试这个
protected void onPostExecute(Integer result)
{
if(valueoftotal!=null)
if(!valueoftotal.equalsIgnoreCase(""))
{
}
}