title: How to create a dynamic layout from json
body: <p>I have layout made from XML and a JSON from which this layout is to be inflated. </p>
  
  <p>The issue is that I have to create a dynamic class extending <code>linearlayout</code> and create this layout and inflate it.</p>
  
  <p>The image below is the same layout inflated two times on the basis of this JSON:-</p>
  
  <pre><code>{
  "data": {
      "layouts": [
          {
              "text": "Loss Date",
              "fromdate": "20-12-2013",
              "todate": "22-12-2014"
          },
          {
              "text": "Loss Date",
              "fromdate": "20-12-2013",
              "todate": "22-12-2014"
          }
      ]
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I have done it using listview.</p>
  
  <p>My question is can I create it by extending <code>linearlayout</code> and create it and use it in a <code>listview</code>/<code>scrollview</code>?
  Here is the XML:-</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;View
      android:layout_width="fill_parent"
      android:layout_height="@dimen/five"
      android:background="@drawable/nav_drawer_background" /&gt;
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical" &gt;
  
      &lt;CheckBox
          android:id="@+id/datefiltercheckbox"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:background="@android:color/transparent"
          android:button="@drawable/selector_checkbox_filter"
          android:focusable="false"
          android:layout_marginLeft="@dimen/five"
          android:paddingLeft="@dimen/thirty"
          android:text="Loss Date"
          android:textSize="@dimen/rightDrawerTitleText"
          android:textStyle="normal" /&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal" &gt;
  
          &lt;TextView
              android:id="@+id/fromdate"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="50"
              android:background="@android:color/transparent"
              android:drawableRight="@drawable/ic_todo"
              android:gravity="center"
              android:text="From: 20-12-2014"
              android:textColor="@android:color/white" /&gt;
  
          &lt;TextView
              android:id="@+id/todate"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="50"
              android:background="@android:color/transparent"
              android:drawableRight="@drawable/ic_todo"
              android:gravity="center"
              android:text="To: 20-12-2014"
              android:textColor="@android:color/white" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  
  &lt;View
      android:layout_width="fill_parent"
      android:layout_height="@dimen/five"
      android:background="@drawable/nav_drawer_background" /&gt;
  </code></pre>
  
  <p></p>
  
  <p><img src="https://i.stack.imgur.com/cUnFS.png" alt="enter image description here"></p>