title: Android : Error when i set size of imageView inside TableRow programmatically
body: <p>When i try to set size of my ImageView objet, i have always same error : </p>
  
  <p><em>Attempt to write to field 'int android.view.ViewGroup$LayoutParams.width' on a null object reference</em></p>
  
  <p>A piece of my code :</p>
  
  <pre><code>    TableLayout tl = (TableLayout)findViewById(R.id.layoutDuNiveau);
      for(int j=0;j&lt;hauteurDuNiveau;j++){
          TableRow tr = new TableRow(this);
          tr.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT));
          for(int i=0;i&lt;largeurDuNiveau;i++){
              imageViewDuNiveau[i][j] = new ImageView(this);
              imageViewDuNiveau[i][j].setImageResource(R.drawable.blanc);
              imageViewDuNiveau[i][j].requestLayout();
              imageViewDuNiveau[i][j].getLayoutParams().width = 20; // ERROR HERE
              imageViewDuNiveau[i][j].getLayoutParams().height = 20; // ERROR HERE
  
  
              switch(tableauDuNiveau[i][j]){
                  case '#':
                      imageViewDuNiveau[i][j].setImageResource(R.drawable.mur);
                  default:
              }
              tr.addView(imageViewDuNiveau[i][j]);
          }
          tl.addView(tr);
      }
  </code></pre>