2012-08-29 96 views
0

我試圖在片段中獲得MapView,但我不知道如何。當我研究這個時,我看到了一些與圖書館的操作,但它改變了我的延伸Fragment在延伸FragmentActivity,然後一切都變得凌亂!MapView中的片段

請幫我把代碼,所以我可以有一個MapView在一個片段。

這裏是我的代碼:

public class MyPlayerFrag extends Fragment{ 

    Context context; 
    ImageView image; 
    TextView caption; 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 
     LinearLayout player_layout = (LinearLayout) inflater.inflate(com.idouchach.casa.tramway.R.layout.player, container, false); 

     image = (ImageView) player_layout.findViewById(R.id.image_view); 
     caption = (TextView) player_layout.findViewById(R.id.caption); 

     return player_layout; 
    } 

    public void updateImage(Content content){ 
     if(image != null){ 
      try{ 
       Bitmap img = BitmapFactory.decodeStream(context.getAssets().open(content.getImg())); 
       image.setImageBitmap(img); 
       image.invalidate(); 
      }catch(Exception ex){ 
       ex.printStackTrace(); 
      } 
     } 
     if(caption != null) 
      caption.setText(content.getTitle()); 
    } 
} 

回答

2

沒有正式支持把一個MapView成片段的手段,對不起。

+0

有沒有官方的方法來做到這一點,但對初學者來說不是太難? –

+0

@SeïfaneIdouchach:就我個人而言,我不會碰到我用10米杆看過的解決方法。 – CommonsWare