title: Android DrawerLayout Click Event -- How to change View
body: <p>I just started an android app that using Drawer Layout. I tried many tutorials to change the layout by clicking the leftbar items.</p>
  
  <p>Here is my code.</p>
  
  <pre><code>public class IndexPageActivity extends ActionBarActivity
      implements NavigationDrawerFragment.NavigationDrawerCallbacks {
  
  /**
   * Fragment managing the behaviors, interactions and presentation of the navigation drawer.
   */
  private NavigationDrawerFragment mNavigationDrawerFragment;
  
  /**
   * Used to store the last screen title. For use in {@link #restoreActionBar()}.
   */
  private CharSequence mTitle;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_index_page);
  
      mNavigationDrawerFragment = (NavigationDrawerFragment)
              getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
      mTitle = getTitle();
  
      // Set up the drawer.
      mNavigationDrawerFragment.setUp(
              R.id.navigation_drawer,
              (DrawerLayout) findViewById(R.id.drawer_layout));
  }
  
  @Override
  public void onNavigationDrawerItemSelected(int position) {
      // update the main content by replacing fragments
      FragmentManager fragmentManager = getSupportFragmentManager();
      FragmentTransaction ft= fragmentManager.beginTransaction();
      ft.replace(R.id.container, PlaceholderFragment.newInstance(position + 1));
      ft.commit();
  
  
  
  
  
   }
  
  public void onSectionAttached(int number) {
      switch (number) {
          case 1:
              mTitle = "Inbox";
  
              break;
          case 2:
              mTitle = "Completed Task";
              break;
          case 3:
              mTitle = "Settings";
              break;
          case 4:
              mTitle = "Change Password";
              break;
          case 5:
              mTitle = "Logout";
              break;
      }
  }
  
  public void restoreActionBar() {
      ActionBar actionBar = getSupportActionBar();
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
      actionBar.setDisplayShowTitleEnabled(true);
      actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_background));
      actionBar.setTitle(mTitle);
  }
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      if (!mNavigationDrawerFragment.isDrawerOpen()) {
          // Only show items in the action bar relevant to this screen
          // if the drawer is not showing. Otherwise, let the drawer
          // decide what to show in the action bar.
      //getMenuInflater().inflate(R.menu.index_page, menu);
          restoreActionBar();
          return true;
      }
      return super.onCreateOptionsMenu(menu);
  }
  
  
  /**
   * A placeholder fragment containing a simple view.
   */
  public static class PlaceholderFragment extends Fragment {
      /**
       * The fragment argument representing the section number for this
       * fragment.
       */
      private static final String ARG_SECTION_NUMBER = "section_number";
  
      /**
       * Returns a new instance of this fragment for the given section
       * number.
       */
      public static PlaceholderFragment newInstance(int sectionNumber) {
          PlaceholderFragment fragment = new PlaceholderFragment();
          Bundle args = new Bundle();
          args.putInt(ARG_SECTION_NUMBER, sectionNumber);
          fragment.setArguments(args);
          return fragment;
      }
  
      public PlaceholderFragment() {
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.fragment_index_page, container, false);
          return rootView;
      }
  
      @Override
      public void onAttach(Activity activity) {
          super.onAttach(activity);
          ((IndexPageActivity) activity).onSectionAttached(
                  getArguments().getInt(ARG_SECTION_NUMBER));
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And my XML Page is :</p>
  
  <pre><code>  &lt;!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. --&gt;
  &lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout"
  android:layout_width="match_parent" android:layout_height="match_parent"
  tools:context="com.example.exactsystm.exactsystem.IndexPageActivity"&gt;
  
  &lt;!-- As the main content view, the view below consumes the entire
       space available using match_parent in both dimensions. --&gt;
  &lt;FrameLayout android:id="@+id/container" android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;
  
  
  &lt;!-- android:layout_gravity="start" tells DrawerLayout to treat
       this as a sliding drawer on the left side for left-to-right
       languages and on the right side for right-to-left languages.
       If you're not building against API 17 or higher, use
       android:layout_gravity="left" instead. --&gt;
  &lt;!-- The drawer is given a fixed width in dp and extends the full height of
       the container. --&gt;
  &lt;fragment android:id="@+id/navigation_drawer"
      android:layout_width="@dimen/navigation_drawer_width" android:layout_height="match_parent"
      android:layout_gravity="start"
      android:name="com.example.exactsystm.exactsystem.NavigationDrawerFragment"
      tools:layout="@layout/fragment_navigation_drawer" /&gt;
  
  &lt;TextView android:layout_width="match_parent" android:layout_height="match_parent"
      android:text="@string/hello_blank_fragment" android:textColor="#ff00" /&gt;
  
  
   &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>This is code is generated by Android studio by default when I create a new Navigation Drawer Activity.</p>
  
  <p>This working finely such as the swiping. but when I select a tab of Navigation It does not going to any sections.</p>
  
  <p>How can i solve this issue ?</p>