我试图从片段到片段的意图,这是我的代码..
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
如何调用我的其他片段?非常感谢提前
答案 0 :(得分:3)
FragmentTransaction ft = getFragmentManager().beginTransaction().replace(R.id.fragment_container, new AddPlacesMapFragment());
ft.commit();
应该这样做!