diff --git a/sample/src/main/java/ua/org/tenletters/sample/SpreadsheetActivity.java b/sample/src/main/java/ua/org/tenletters/sample/SpreadsheetActivity.java index a45cf65..c62dacd 100644 --- a/sample/src/main/java/ua/org/tenletters/sample/SpreadsheetActivity.java +++ b/sample/src/main/java/ua/org/tenletters/sample/SpreadsheetActivity.java @@ -19,8 +19,8 @@ public class SpreadsheetActivity extends AppCompatActivity { - private static final int NUM_COLUMNS = 10; - private static final int NUM_ROWS = 30; + private static int NUM_COLUMNS = 10; + private static int NUM_ROWS = 30; private TableLayout columns; private TableLayout rows; @@ -37,6 +37,8 @@ public void onCreate(Bundle savedInstanceState) { setupScrollers(); populateTables(); + + rePopulateExistingTables(); } private void setupActionBar() { @@ -71,6 +73,30 @@ private void setupScrollers() { verticalScroller.scrollTo(0, top); }); } + + /** + * reset the existing Tables + */ + + private void rePopulateExistingTables() { + + NUM_COLUMNS = 5; + NUM_ROWS = 4; + + // reset if views are already set + if (columns.getChildCount()>0) { + columns.removeAllViews(); + } + if (rows.getChildCount()>0) { + rows.removeAllViews(); + } + if (content.getChildCount()>0) { + content.removeAllViews(); + } + + populateTables(); + + } /** * Fills "Column" and "Row" headers, and "Content" table with inflated cell views