title: Unable to add Fragment to the Navigation Drawer
body: <p>I am trying to add a Fragment inside the Navigation Drawer but strangely the final output does not seems like a navigation drawer. In the image below The Drawer is static on the page with no Frame layout content and toolbar. My Doubt is whether can we add the RecyclerView inside Fragment and then display it or should I just use the RecyclerView?</p>
  
  <p><a href="https://i.stack.imgur.com/5ZwT0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5ZwT0.png" alt="enter image description here"></a></p>
  
  <p>Following are the files:</p>
  
  <p>MainActivity.java:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      setupToolbar();
      drawerLayout = (DrawerLayout) findViewById(R.id.drawerMainActivity);
      setupDrawerToggle();
      Fragment squadFragment = new SquadFragment();
      FragmentTransaction fragmentTransaction =  getFragmentManager().beginTransaction();
      fragmentTransaction.replace(R.id.containerView,squadFragment,null);
      fragmentTransaction.commit();
  
  }
  
  void setupToolbar(){
      toolbar = (Toolbar) findViewById(R.id.toolBar);
      setSupportActionBar(toolbar);
      getSupportActionBar().setDisplayShowHomeEnabled(true);
  }
  
  void setupDrawerToggle(){
      drawerToggle = new  ActionBarDrawerToggle(this,drawerLayout,toolbar,R.string.app_name,R.string.app_n   ame);
      //This is necessary to change the icon of the Drawer Toggle upon state  change.
      drawerToggle.syncState();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>ReyclerViewFragment.java :</p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container,  Bundle savedInstanceState) {
      View v = inflater.inflate(R.layout.recyclerfragment,container,false);
  
  
      navTitles = getResources().getStringArray(R.array.navDrawerItems);
      navIcons = getResources().obtainTypedArray(R.array.navDrawerIcons);
      recyclerViewAdapter = new  Adapter(navTitles,navIcons,getActivity().getApplicationContext());
     recyclerView = (RecyclerView) v.findViewById(R.id.recyclerView);
      recyclerView.setAdapter(new  Adapter(null,null,getActivity().getApplicationContext()));
      recyclerView.setLayoutManager(new  LinearLayoutManager(getActivity().getApplicationContext()));
      recyclerView.setAdapter(recyclerViewAdapter);
  
      return v;
  }
  </code></pre>
  
  <p>activity_main.xml :</p>
  
  <pre><code> &lt;android.support.v4.widget.DrawerLayout   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:local="http://schemas.android.com/apk/res-auto"
   android:id="@+id/drawerMainActivity"
   android:layout_width="match_parent"
   android:layout_height="match_parent"&gt;
  
   &lt;LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"&gt;
      &lt;include android:id="@+id/toolBar"
          layout="@layout/app_bar"/&gt;
      &lt;FrameLayout
          android:orientation="vertical"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:id="@+id/containerView"&gt;
  
  
      &lt;/FrameLayout&gt;
  &lt;/LinearLayout&gt;
  
  &lt;fragment
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:name="com.example.hp.recyclernavigation.RecyclerFragment"
      android:id="@+id/fragment"
      &gt;
  
      &lt;/fragment&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>recyclerfragment.xml:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="match_parent" &gt;
  
  &lt;android.support.v7.widget.RecyclerView
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:id="@+id/recyclerView"
      android:background="#FFFFFF"
      android:layout_gravity="start"
      /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Adapter.java:</p>
  
  <pre><code> Adapter(String[] titles , TypedArray icons , Context context){
  
      this.titles = titles;
      this.icons = icons;
      this.context = context;
   //        inflator=LayoutInflater.from(context);
   }
  
  public class ViewHolder extends RecyclerView.ViewHolder  {
  
      TextView  navTitle;
      ImageView navIcon;
      Context context;
  
      public ViewHolder(View drawerItem , int itemType , Context context){
  
          super(drawerItem);
          this.context = context;
        //  drawerItem.setOnClickListener(this);
          if(itemType==1){
              navTitle = (TextView) itemView.findViewById(R.id.tv_NavTitle);
              navIcon = (ImageView) itemView.findViewById(R.id.iv_NavIcon);
          }
      }
  }
  
   @Override
   public Adapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)    {
  
      LayoutInflater layoutInflater = (LayoutInflater)  parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
      if(viewType==1){
          View itemLayout =    layoutInflater.inflate(R.layout.drawer_item_layout,null);
          return new ViewHolder(itemLayout,viewType,context);
      }
      else if (viewType==0) {
          View itemHeader =   layoutInflater.inflate(R.layout.header_layout,null);
          return new ViewHolder(itemHeader,viewType,context);
      }
      return null;
  }
  @Override
  public void onBindViewHolder(Adapter.ViewHolder holder, int position) {
  
      if(position!=0){
          holder.navTitle.setText(titles[position - 1]);
          holder.navIcon.setImageResource(icons.getResourceId(position-1,-1));
      }
  }
  @Override
  public int getItemCount() {
      return titles.length+1;
  }
  @Override
  public int getItemViewType(int position) {
      if(position==0)return 0;
      else return 1;
  }
  </code></pre>
  
  <p>Can Someone Please help me!!</p>