I added a NavigationDrawer
Activity
in my Android project.
So I started adding 1 Fragment
and it will be launched through one of the items in the NavigationDrawer
.
My problem is that whenever I launch the Fragment
, the content (in green) is not being changed. But contents of the new Fragment
is there (in red).
Here's my code in changing the fragment:
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
Fragment newFragment;
android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
if (id == R.id.nav_gradesheet) {
// Handle the camera action
newFragment = new GradeSheet();
transaction.replace(R.id.yeah2, newFragment);
transaction.addToBackStack(null);
transaction.commit();
} else if (id == R.id.nav_summarygradesheet) {
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}