Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么在僵尸谷歌地图上出现空指针异常?_Android_Google Maps - Fatal编程技术网

Android 为什么在僵尸谷歌地图上出现空指针异常?

Android 为什么在僵尸谷歌地图上出现空指针异常?,android,google-maps,Android,Google Maps,在我的应用程序中,目镜地图缩放时出现空指针异常 我已提出检查条件,但问题仍然存在,请任何人帮助我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

在我的应用程序中,目镜地图缩放时出现空指针异常 我已提出检查条件,但问题仍然存在,请任何人帮助我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);
    }
@覆盖
受保护的void onPostExecute(整数结果)
{
如果(!valueoftotal.equalsIgnoreCase(“”)&!valueoftotal.equalsIgnoreCase(null))
{
if(Integer.parseInt(valueoftotal)>0&&Integer.parseInt(valueoftotal)1)
{
对于(inti=0;i100)
{
显示消息(valueoftotal+“已找到列表。\n放大,按下面的“定位”按钮或选择上面的“优化”按钮以显示较少的属性。”);
lineartabbar.setBackgroundResource(R.drawable.mapwithoutlist);
linearbottom2.可设置可点击(false);
}
else if(Integer.parseInt(valueoftotal)==0)
{
GoneAnimations();
lineartabbar.setBackgroundResource(R.drawable.mapwithoutlist);
linearbottom2.可设置可点击(false);
customizeDialog=新的customizeDialog(活动);
自定义对话框设置标题(“对不起”);
customizeDialog.setMessage(“未找到列表”);
customizeDialog.show();
}
}
super.onPostExecute(结果);
}
很抱歉我的解释。

代替写作

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

protected void onPostExecute(Integer result) 
{
    if(valueoftotal!=null)
    if(!valueoftotal.equalsIgnoreCase(""))
    {
    }
}
而不是写作

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

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

“valueoftotal.equalsIgnoreCase(null)”不是检查valueoftotal是否为null或notthanx的正确语法,但我的异常来自填充或覆盖。请查看日志异常是否有出现?我的意思是说