2014-01-15 169 views
0

我可是從片段片段試圖意圖,這裏是我的代碼..如何意圖從碎片到碎片?

 public boolean onOptionsItemSelected(MenuItem item) 
     { 
      switch(item.getItemId()){ 
      case R.id.action_add_place: 

      FragmentTransaction ft = getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AddPlacesMapFragment()); 
    ft.commit(); 
      } 


      return true; 
     } 

XML

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@id/maplayout" > 

<com.google.android.gms.maps.MapView 
    android:id="@+id/map1" 
    android:layout_below="@+id/buttonResetPins" 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent" > 

</com.google.android.gms.maps.MapView> 


</RelativeLayout> 

這裏是日誌跟蹤

01-15 15:23:33.268: E/FragmentManager(19749): No view found for id 0x7f060005 (com.c4a.itravellipaph:id/maplayout) for fragment AddPlacesMapFragment{4322dc18 #1 id=0x7f060005} 
01-15 15:23:33.268: E/FragmentManager(19749): Activity state: 
01-15 15:23:33.268: E/FragmentManager(19749): Local Activity 4201c1c0 State: 
01-15 15:23:33.268: E/FragmentManager(19749):  mResumed=true mStopped=false mFinished=false 
01-15 15:23:33.268: E/FragmentManager(19749):  mLoadersStarted=true 
01-15 15:23:33.268: E/FragmentManager(19749):  mChangingConfigurations=false 
01-15 15:23:33.268: E/FragmentManager(19749):  mCurrentConfig={1024 0 1.0 515mcc2mnc en_PH 

如何調用我的其他片段?非常感謝提前

回答

2
FragmentTransaction ft = getFragmentManager().beginTransaction().replace(R.id.fragment_container, new AddPlacesMapFragment()); 
    ft.commit(); 

這應該做到這一點!

+0

這是正確的。對不起,我看錯了這個問題 - 我的回答是,如果你想傳遞數據到你的片段。 – Jerryl15

+0

不,我只是想從目前的片段意圖到下一個片段 – AndroidNewbie

+0

@adnan看到我編輯的帖子 – AndroidNewbie