我在我的应用程序中提供了NavigationDrawer。使用手动在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);
}
在这里,我必须把我的屏幕像碎片,但现在我的屏幕是活动的,我想从我的活动而移动用最少的代码改变片段。我能做什么?
你不undarstand问题。将MainActivity从Activity转换为FragmentActivity或ActionBarActivity不是问题。在Fragment中重写NotMainActivity(将在NavigationDrawer中填充的内容)中的问题。 –