title: dynamic table in android studio
body: <p>i need help to create a table in android studio,please see my code and help me...this code has error when i want to run it in my device!</p>
  
  <pre><code>TableLayout table=new TableLayout(this);
  
  public void _start(View v) {
      CreateTable();
  }
  public void CreateTable() {
      for (int row = 0; row &lt; 3; row++) {
          TableRow groupCells = new TableRow(this);
          for(int column=0;column&lt;3;column++) {
              TextView cell = CreateCells(row, column);
  
              groupCells.addView(cell);
          }
          table.addView(groupCells);
      }
  }
  
  private TextView CreateCells(int row, int column) {
      TextView cell = new TextView(this);
      cell.setId(Integer.valueOf(row + "," + column));
      cell.setWidth(20);
      cell.setHeight(20);
      cell.setText("");
      cell.setX((findViewById(R.id._table).getWidth()/2)-(20*row)+(cell.getWidth()/2));
      cell.setY((findViewById(R.id._table).getHeight()/2)-(20*column)+(cell.getHeight()/2));
      cell.setVisibility(View.VISIBLE);
      return cell;
  }
  </code></pre>
  
  <p>and i have this errors:</p>
  
  <p>java.lang.NullPointerException   at android.widget.LinearLayout.forceUniformHeight(LinearLayout.java:1380)   at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1368)   at android.widget.TableRow.onMeasure(TableRow.java:114)   at android.view.View.measure(View.java:17430)   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)   at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)   at android.widget.TableLayout.measureChildBeforeLayout(TableLayout.java:464)   at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)   at android.widget.TableLayout.measureVertical(TableLayout.java:476)   at android.widget.TableLayout.onMeasure(TableLayout.java:439)   at android.view.View.measure(View.java:17430)   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)   at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)   at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1083)   at android.widget.LinearLayout.onMeasure(LinearLayout.java:615)   at android.view.View.measure(View.java:17430)   at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:727)   at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:463)   at android.view.View.measure(View.java:17430)   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)   at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)   at android.view.View.measure(View.java:17430)   at android.widget.LinearLayout.measureVertical(LinearLayout.java:875)   at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)   at android.view.View.measure(View.java:17430)   at android.widget.LinearLayout.measureVertical(LinearLayout.java:875)   at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)   at android.view.View.measure(View.java:17430)</p>
  
  <p>and i dont know what is this!
  please help me...</p>