gpt4 book ai didi

android - 为什么在缩放谷歌地图时出现空指针异常?

转载 作者:行者123 更新时间:2023-11-30 04:08:40 25 4
gpt4 key购买 nike

在我的应用程序中,很少不总是,缩放护目镜 map 时出现空指针异常 我已经检查了条件但问题仍然存在请任何人帮助我堆栈跟踪是:-

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);
}

抱歉我的解释。

最佳答案

而不是写作

protected void onPostExecute(Integer result) 
{
if(!valueoftotal.equalsIgnoreCase("") && !valueoftotal.equalsIgnoreCase(null))
{
}
}

试试这个

protected void onPostExecute(Integer result) 
{
if(valueoftotal!=null)
if(!valueoftotal.equalsIgnoreCase(""))
{
}
}

关于android - 为什么在缩放谷歌地图时出现空指针异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11203783/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com