2013-07-22 37 views
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"); 
      } 
     }); 
    } 

現在我有兩個設備,我調試,第一個是三星galaxy s2與android版本4.1.2和另一個是與Android版本4.2.2, nexus 4問題是,當我放大我的nexus 4我看到一個空白屏幕(灰色方塊,我只能看到縮放按鈕),並在上我的sgs2我可以放大和縮小沒有問題,我看到一切都完美。

可能是什麼問題? 現在,我正在爲這個問題苦苦掙扎一段時間。 預先感謝所有能夠幫助的人。

Best, Shalom Melamed。

回答

0

問題通過完全刪除我的nexus 4並重新安裝解決。

希望它能幫助任何人。