title: Arrangement of buttons
body: <p>I have created an array of buttons but all the buttons are arranged in vertical order.<br>
  I want 3 buttons in one row, next 3 buttons in second row and so on.</p>
  
  <p>Here is my code please check it where it should be done.</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      LinearLayout layout = (LinearLayout)findViewById(R.id.liLayout);
      for (int i = 1; i &lt; 10; i++)
      {
  
          LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
  
                  LinearLayout.LayoutParams.WRAP_CONTENT,
                  LinearLayout.LayoutParams.WRAP_CONTENT
          );
          Button b = new Button(this);
          b.setText("" + i);
          b.setId(100 + i);
          b.setWidth(50);
          b.setHeight(20);
          layout.addView(b, p);
  
      }
  }
  </code></pre>