我在我的应用中提供了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。我能做什么?