title: How to Inflate new layout inside cardview dynamically
body: <p>I am trying to inflate the second XML inside cardview dynamically, but it throws null pointer exception.When I am trying to do hard code(by including directly inside card view layout) it works well.Is there any other way to inflate new XML dynamically?</p>
  
  <p>CardView Layout</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.CardView
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:id="@+id/room_detail_cards"
      android:layout_height="wrap_content"&gt;
      &lt;LinearLayout
          android:id="@+id/room_detail_Linear_layout"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"&gt;
  
          &lt;include layout="@layout/module_type_5"/&gt;
          &lt;!--&lt;include layout="@layout/module_type_3"/&gt;--&gt;
          &lt;!--&lt;It Works well when i hard code the layout here/&gt;--&gt;
  
  &lt;/LinearLayout&gt;
  &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>
  
  <p>RecyclerAdapter.java(onCreateViewHolder)</p>
  
  <pre><code>@Override
  public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      layout= (LinearLayout) parent.findViewById(R.id.room_detail_Linear_layout);
      View itemView = LayoutInflater.
                  from(parent.getContext()).
                  inflate(R.layout.module_type_3, layout, false);
     layout.addView(itemView);             //NULL Pointer Exception occurs here
      View itemView1 = LayoutInflater.
              from(parent.getContext()).
              inflate(R.layout.room_detail_card_view, null, false);
  
      return new ViewHolder(itemView1);
  }
  </code></pre>
  
  <p>First layout XML(module_type_5)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
      &lt;TextView
          android:hint="module"
          android:id="@+id/module_5"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" /&gt;
      &lt;LinearLayout
          android:padding="10dp"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
          &lt;ImageView
              android:src="@drawable/add"
              android:id="@+id/switch_1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" /&gt;
          &lt;ImageView
              android:src="@drawable/add"
              android:id="@+id/switch_2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" /&gt;
          &lt;ImageView
              android:src="@drawable/add"
              android:id="@+id/switch_3"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" /&gt;
          &lt;ImageView
              android:src="@drawable/add"
              android:id="@+id/switch_4"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" /&gt;
          &lt;ImageView
              android:src="@drawable/add"
              android:id="@+id/switch_5"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Second XML Layout(module_type_3)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:padding="5dp"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
      &lt;TextView
          android:hint="module"
          android:id="@+id/module_5"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" /&gt;
      &lt;LinearLayout
          android:padding="10dp"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
          &lt;ImageView
              android:src="@drawable/add"
              android:id="@+id/switch_1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" /&gt;
          &lt;ImageView
              android:src="@drawable/add"
              android:id="@+id/switch_2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" /&gt;
          &lt;ImageView
              android:src="@drawable/add"
              android:id="@+id/switch_3"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" /&gt;
  &lt;/LinearLayout&gt;
  
      &lt;/LinearLayout&gt;
  </code></pre>