title: Dynamically setting the table layout
body: <p>I am trying to dynamically set a table layout in an activity. The number of rows and columns depend upon the user's input.</p>
  
  <p><strong>So the problem</strong> - Every time number of rows are fine but number of columns (textViews) in each row is always equal to the lowest value of the array <code>no_periods[ ]</code>. For eg. if no_days has a value 5, <code>no_periods[]</code> have 2, 3, 4, 5, 6 values. The table will have 5 rows but each row will have only 2 textViews instead of 2, 3, 4, 5, 6 textViews in the respective rows.</p>
  
  <p>Here is the code I am trying with</p>
  
  <pre><code>        //loop to set the rows and text view in the table layout of activity_home  
      for (int i = 0; i &lt; no_days; i++) {
  
      tableRow = new TableRow(TimeTable.this);
  
      for (int j = 0; j &lt;no_periods[i]; j++) {
  
         textView = new TextView(TimeTable.this);
                 textView.setHint("Click");
                 textView.setClickable(true);
                 textView.setOnClickListener(click_listen);
  
                 int maxpixels = screenWidth/(no_periods[i]);
                 int minpixels = maxpixels; 
  
                 textView.setPadding(10, 10, 10, 10);
  
                 textView.setMaxWidth(maxpixels);
                 textView.setMinWidth(minpixels);
  
                 tableRow.addView(textView);
  
             }
             tableLayout.addView(tableRow);
  
         }
  </code></pre>