title: Why can't i add time in my navigation when i have the code in main?
body: <p>I made a separate demo app that tells the time.I want to add it to the navigation windows (the hamburger window).However when i put the code in Main where the code for the Nav bar is it crashes.</p>
  
  <pre><code>package com.example.user.navigationdrawer;
  
  import android.app.Fragment;
  import android.app.FragmentManager;
  import android.os.Bundle;
  import android.support.design.widget.FloatingActionButton;
  import android.support.design.widget.Snackbar;
  import android.view.View;
  import android.support.design.widget.NavigationView;
  import android.support.v4.view.GravityCompat;
  import android.support.v4.widget.DrawerLayout;
  import android.support.v7.app.ActionBarDrawerToggle;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.widget.TextView;
  
  import java.text.SimpleDateFormat;
  import java.util.Calendar;
  import java.util.Date;
  import java.util.Locale;
  
   public class MainActivity extends AppCompatActivity
      implements NavigationView.OnNavigationItemSelectedListener {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      FloatingActionButton fab = (FloatingActionButton)      findViewById(R.id.fab);
      fab.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                      .setAction("Action", null).show();
          }
      });
  
      DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
              this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
      drawer.setDrawerListener(toggle);
      toggle.syncState();
      //This code
      TextView theTime = (TextView) findViewById(R.id.theT);
      SimpleDateFormat df = new SimpleDateFormat("EEEE, MMMM dd, yyyy", Locale.ENGLISH);
      Date today = Calendar.getInstance().getTime();
      String reportDate = df.format(today);
      theTime.setText(reportDate);
      //This code
  
      NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
      navigationView.setNavigationItemSelectedListener(this);
  
  
  }
  
  @Override
  public void onBackPressed() {
      DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      if (drawer.isDrawerOpen(GravityCompat.START)) {
          drawer.closeDrawer(GravityCompat.START);
      } else {
          super.onBackPressed();
      }
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
  
  
      return super.onOptionsItemSelected(item);
  }
  
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
      // Handle navigation view item clicks here.
      int id = item.getItemId();
      FragmentManager fragmentManager = getFragmentManager();
  
      if (id == R.id.nav_first_layout) {
          fragmentManager.beginTransaction()
                  .replace(R.id.content_frame
                          , new FirstFragment())
                  .commit();
      } else if (id == R.id.nav_second_layout) {
          fragmentManager.beginTransaction()
                  .replace(R.id.content_frame
                          , new SecondFragment())
                  .commit();
      } else if (id == R.id.nav_third_layout) {
          fragmentManager.beginTransaction()
                  .replace(R.id.content_frame
                          , new ThirdFragment())
                  .commit();
      } else if (id == R.id.nav_share) {
  
      }
  
      DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      drawer.closeDrawer(GravityCompat.START);
      return true;
  
  
   }
   }
  </code></pre>
  
  <p>This is my Xml </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="200dp"
  android:background="@drawable/side_nav_bar"
  android:gravity="bottom"
  android:orientation="vertical"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  android:theme="@style/ThemeOverlay.AppCompat.Dark"&gt;
  
  
  &lt;ImageView
      android:id="@+id/imageView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:adjustViewBounds="true"
      android:layout_gravity="center_vertical"
      android:src="@mipmap/sijny"
      android:contentDescription="" /&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingTop="7dp"
      android:paddingBottom="2dp"
      android:text="SIJNY Islamic Center"
      android:textAppearance="@style/TextAppearance.AppCompat.Body1"
      android:id="@+id/textView3"
      android:textStyle="normal|bold"
      android:adjustViewBounds="true" /&gt;
  
  &lt;TextView
      android:id="@+id/theT"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingBottom="2dp"
      android:textColor="#FFFF"
      android:text="Time" /&gt;
  
  &lt;TextView
      android:id="@+id/textView6"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textColor="#FFFF"
      android:text="13 Ramadan 1436" /&gt;
  
  
   &lt;/LinearLayout&gt;
  </code></pre>