我在我的应用程序中提供 NavigationDrawer。
我在http://developer.android.com/training/implementing-navigation/nav-drawer.html上使用手册
/**
* Swaps fragments in the main content view
*/
private void selectItem(int position) {
// Create a new fragment and specify the planet to show based on
// position
Fragment fragment = new PlanetFragment();
Bundle args = new Bundle();
args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
fragment.setArguments(args);
// Insert the fragment by replacing any existing fragment
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
// Highlight the selected item, update the title, and close the drawer
mDrawerList.setItemChecked(position, true);
setTitle(mPlanetTitles[position]);
mDrawerLayout.closeDrawer(mDrawerList);
}
在这里,我必须像 Fragment 一样放置我的屏幕,但现在我的屏幕是 Activity,我想以最少的代码更改从我的 Activity 移动到 Fragment。我能做什么?