Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can try this and see if it's what your are looking for.</p> <p>main.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;Button android:text="Button" android:id="@+id/button1" android:layout_height="wrap_content" android:layout_width="wrap_content"/&gt; &lt;TableLayout android:id="@+id/tableLayout1" android:layout_height="wrap_content" android:layout_width="fill_parent" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Your Activity class:</p> <pre><code>public class mainActivity extends Activity implements OnClickListener { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( R.layout.main ); Button b = (Button) findViewById( R.id.button1 ); b.setOnClickListener( this ); } @Override public void onClick(View v) { TableLayout table = (TableLayout) findViewById( R.id.tableLayout1 ); int buttonsInRow = 0; int numRows = table.getChildCount(); TableRow row = null; if( numRows &gt; 0 ){ row = (TableRow) table.getChildAt( numRows - 1 ); buttonsInRow = row.getChildCount(); } if( numRows == 0 || buttonsInRow == 3 ){ row = new TableRow( this ); table.addView( row ); buttonsInRow = 0; } if( buttonsInRow &lt; 3 ){ Button b = new Button( this ); row.addView( b, 100, 50 ); } } } </code></pre> <p>Hope it helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload