title: Android Studio creating board programmatically
body: <p>I am currently trying to create my first board Android game and struggling with my layout. My code only creates one row of the board. I have read almost every post but could not find anything useful.</p>
  
  <pre><code>public class Nonogram extends AppCompatActivity {
  
  private Field field = new Field(10,10,75);
  
  private ImageView[][] board = new ImageView[field.getRowCount()][field.getColumnCount()];
  
  Context context;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_nonogram);
      context = this;
      draw();
  }
  
  private void draw(){
  
      RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.nonogram);
  
      for(int row = 0; row &lt; field.getRowCount(); row ++) {
  
          LinearLayout rowl = new LinearLayout(context);
  
          for (int column = 0; column &lt; field.getColumnCount(); column++) {
  
              board[row][column] = new ImageView(context);
  
              if (field.getUserTiles()[row][column].getState() == TileState.FILLED) {
                  board[row][column].setBackgroundResource(R.drawable.filled);
  
              } else if (field.getUserTiles()[row][column].getState() == TileState.EMPTY) {
                  board[row][column].setBackgroundResource(R.drawable.empty);
  
              } else {
                  board[row][column].setBackgroundResource(R.drawable.marked);
              }
  
              rowl.addView(board[row][column]);
          }
          relativeLayout.addView(rowl);
      }
  }
  </code></pre>
  
  <p>The XML is just the Relative Layout.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:id="@+id/nonogram"
  android:background="@drawable/menu_background"
  tools:context="pocketfun.org.pocketfun.nonogram.Nonogram"&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>