0

我正在使用 GoogleMap V2,我有一个 gridView 和一个这样的 mapView:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:weightSum="1" >

        <com.google.android.gms.maps.MapView
            android:id="@+id/map_view"
            android:layout_width="match_parent"
            android:layout_height="0dp"            
            android:layout_weight="0.5" />

        <GridView
            android:id="@+id/gv_all_pubs"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.5"
            android:background="@color/BurlyWood"
            android:columnWidth="300dp"
            android:horizontalSpacing="5dp"
            android:numColumns="auto_fit"
            android:stretchMode="columnWidth"
            android:verticalSpacing="3dp" />
    </LinearLayout>

</FrameLayout>

代码是:

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
    {
        View view = null;
        try
        {
            view = inflater.inflate(R.layout.all_pubs_layout, container, false);            

            mapView = (MapView)view.findViewById(R.id.map_view);
            mapView.onCreate(savedInstanceState);           
            map = mapView.getMap();

            //set the map options
            map.setMyLocationEnabled(false);
            map.getUiSettings().setMyLocationButtonEnabled(false);
            map.getUiSettings().setZoomControlsEnabled(true);
            map.setMapType(GoogleMap.MAP_TYPE_NORMAL);

            map.getUiSettings().setCompassEnabled(true);            

            try 
            {
                MapsInitializer.initialize(mContext);
            }
            catch (Exception e){}                       

            gvAllPubs = (GridView)view.findViewById(R.id.gv_all_pubs);
            gvAdapter = new AllPubsGridViewAdapter(mContext, App.pubSortedByLastUpdate);
            gvAllPubs.setAdapter(gvAdapter);
            gvAllPubs.setOnItemClickListener(gridViewClickListener);

            //select the first item in the list
            try 
            {
                gvAllPubs.setSelection(lastPubSelected);
                drawLastPubSelected(lastPubSelected);
            }
            catch (Exception e) {}
        }
        catch(Exception e){}
        return view;
    }

而gridview项目点击监听器是:

OnItemClickListener gridViewClickListener = new OnItemClickListener()
    {
        @Override
        public void onItemClick(AdapterView<?> adapter, View view, int position, long id) 
        {
            lastPubSelected = position;         
            drawLastPubSelected(lastPubSelected);       
        }
    };

private void drawLastPubSelected(int position)
    {
        //get the selected pub
        PubObj selectedPub = App.pubSortedByLastUpdate.get(position);
        double pubLat = selectedPub.pubLatitude;
        double pubLong = selectedPub.pubLongtitude;

        //get the pub location
        LatLng pubLocation = new LatLng(pubLat, pubLong);
        CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(pubLocation, 15);
        //zoom the map to the pub
        map.animateCamera(cameraUpdate);

        //create the marker at the pub location
        MarkerOptions mapMarkerOption = new MarkerOptions();
        mapMarkerOption.position(pubLocation);
        mapMarkerOption.title(selectedPub.pubName.toString() +" - "+selectedPub.pubAddress.toString());
        mapMarkerOption.snippet(selectedPub.pubCurrentStatus.toString());
        mapMarkerOption.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_VIOLET));
        mapMarkerOption.draggable(false);

        map.clear();
        Marker marker = map.addMarker(mapMarkerOption);
        marker.showInfoWindow();

        //on marker click open pub details activity
        map.setOnInfoWindowClickListener(new OnInfoWindowClickListener()
        {           
            @Override
            public void onInfoWindowClick(Marker marker)
            {
                //open pub details activity
                Log.d("pubs", "a");
            }
        });
    }

现在我有两个要调试的设备,第一个是 samsung galaxy s2 和 android 版本 4.1.2,另一个是 nexus 4 和 android 版本 4.2.2,问题是当我放大我的 nexus 4 时看到一个空白屏幕(灰色方块,我只能看到缩放按钮),在我的 sgs2 上,我可以毫无问题地放大和缩小,我看到一切都很完美。

可能是什么问题?我在这个问题上挣扎了一段时间。提前感谢所有可以提供帮助的人。

最好的,沙洛姆·梅拉梅德。

4

1 回答 1

0

通过从我的nexus 4中完全删除并重新安装它解决了问题。

希望它会帮助任何人。

于 2013-07-23T19:19:37.487 回答