我在我的應用程序中提供了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中填充的內容)中的問題。 –