title: Add Buttons to TableRow Dynamically
body: <p>Hello I want to click a button that will add a new button to a table row every time it is clicked. After 3 buttons have been added to the row, I want to dynamically create a new table row and add a new button to it.</p>
  
  <p>I know how to add a row with a button(s) to a tableLayout if I click a button. I don't know how to modify the table row every time I click so I can add an additional button.</p>
  
  <p>Any advice would be quite helpful and appreciated.</p>
  
  <p>Following is my code but this is not perfect</p>
  
  <pre><code>public class DynamicTableView extends Activity {
  
      TableLayout mTlayout;
      String[] mTextofButton = { "Dipak", "E", "I", "J", "L",
              "M", "G", "R", "N", "T", "H", "P",
              "K", "Y", "V" };
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          mTlayout = (TableLayout) findViewById(R.id.mTlayout);
  
  
          TableRow tr=new TableRow(this);
          for(int i=0;i&lt;mTextofButton.length;i++){
              Button btn=new Button(this);
              btn.setText(mTextofButton[i]);
              tr.addView(btn);
  
          }   
          mTlayout.addView(tr);
      }
  }
  </code></pre>
  
  <p>Thanks in advance. </p>