title: Building table layout dynamically at run time from XML
body: <p>New to android, I would like to have a view like below with actual values.</p>
  
  <p><a href="https://i.stack.imgur.com/4ZWeC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4ZWeC.png" alt="enter image description here"></a></p>
  
  <p>My code to dummy values is as below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_marginTop="10dp"&gt;
  
      &lt;TableRow
          android:background="#607D8B"
          android:padding="5dp"&gt;
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="Title" /&gt;
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="Due On" /&gt;
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="" /&gt;
      &lt;/TableRow&gt;
  
      &lt;TableRow
          android:background="#ECEFF1"
          android:padding="5dp"&gt;
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="Access to Knowledge" /&gt;
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="12 Feb 2016" /&gt;
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="Renew" /&gt;
      &lt;/TableRow&gt;
  
      &lt;TableRow
          android:background="#ECEFF1"
          android:padding="5dp"&gt;
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="Achivement" /&gt;
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="16 Feb 2016" /&gt;
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="Renew" /&gt;
      &lt;/TableRow&gt;
      &lt;TableRow
          android:background="#ECEFF1"
          android:padding="5dp"&gt;
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="God of small things" /&gt;
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="22 Feb 2016" /&gt;
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="Renew" /&gt;
      &lt;/TableRow&gt;
  
      &lt;Button
          android:text="Renew all" /&gt;
  
  &lt;/TableLayout&gt;
  </code></pre>
  
  <p>I am getting the values from XML from webservices and parsing it to show in my table view.</p>
  
  <p>I am using DocumentBuilderFactory to parse my XML. Here my XML file is in String str.</p>
  
  <pre><code> builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                              InputSource src = new InputSource();
                              src.setCharacterStream(new StringReader(str));
  
                              Document doc = builder.parse(src);
                              String title = `doc.getElementsByTagName("title").item(0).getTextContent();`
  </code></pre>
  
  <p>Normally I use </p>
  
  <pre><code>TitleTxt.setText("Title: " + title);
  
  PublisherTxt.setText("Publisher: " + publisher)
  </code></pre>
  
  <p>to show the results in my view.</p>
  
  <p>I have multiple questions:
  Q1 what modifications are needed in layout file to show - actual values and not the dummy values?
  Q2 how to get the array values in XML parsing to show in my layout file?
  Q3 how to show the XML parsed results in my table view - dynamically at runtime?</p>
  
  <p>These are related queries, so had to put in the same question. Some of it may sound simple, but being new to Android, I am not able to figure out. Also tried to find a sample code to do it but could not find. Not sure if I am using the right keywords to search for what I am looking for.</p>
  
  <p>Any links to sample code or which exact keywords to look for to search my issue solution or suggestions will also be appreciated. </p>
  
  <p>Thanks in advance.</p>