List of usage examples for android.widget TableLayout post
public boolean post(Runnable action)
Causes the Runnable to be added to the message queue.
From source file:at.ac.uniklu.mobile.sportal.DashboardUpcomingDatesFragment.java
private void adjustDateListHeight() { final TableLayout dateListTable = (TableLayout) getView().findViewById(R.id.dates); // post the action to the UI thread to defer execution until the view has been drawn dateListTable.post(new Runnable() { @Override/*w w w . j av a 2 s .co m*/ public void run() { // get first row View v = dateListTable.getChildAt(0); int entryHeight; if (v != null && (entryHeight = v.getMeasuredHeight()) > 0) { int numPossibleVisibleRows = dateListTable.getMeasuredHeight() / entryHeight; int numExisitingRows = Math.min(numPossibleVisibleRows, dateListTable.getChildCount()); int numVisibleRows = Math.min(numExisitingRows, numPossibleVisibleRows); // remove rows that are outside the screen if (numExisitingRows > numVisibleRows) { dateListTable.removeViews(numVisibleRows, numExisitingRows - numVisibleRows); } // toggle visibility of rows inside the screen for (int x = 0; x < numVisibleRows; x++) { dateListTable.getChildAt(x).setVisibility(View.VISIBLE); } } else { Log.d(TAG, "cannot adjust list height"); } } }); }