Android LinearLayout Programmatically Set Vertical or Horizontal

In Android you might want to set the orientation programmatically in Java for a LinearLayout. You do like this:

LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
// or horizontal like this
layout.setOrientation(LinearLayout.HORIZONTAL);

LinearLayout.HORIZONTAL also got the integer value 0 and Vertical got 1.

Further take a look at LinearLayout | Android Developers