List of usage examples for android.widget TableLayout removeViews
public void removeViews(int start, int count)
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 ww. java2 s . com 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"); } } }); }