title: How Do I Delete Rows From TableLayout?
body: <p>I'm a noob to android development and I am having trouble deleting rows from a TableLayout that that is instantiated with one row inside a viewpager.  When user click a button 12 more rows are added.  Then when users click the button again those 12 rows should be deleted and another set of rows should be added.  However, whenever I try to delete the rows from the TableLayout, only the odd number rows are deleted instead of all the rows.  Any help resolving this is greatly appreciated.</p>
  
  <p>ViewPager (where tablelayout instantiated)</p>
  
  <pre><code> case 2:
                  resId = R.layout.suggestedremedy_layout;    
                  view = inflater.inflate(resId, null);
                  remedyDescription = (TextView)view.findViewById(R.id.remedy_description);
                  remedyCause = (TextView)view.findViewById(R.id.remedy_cause);
                  remedyHerbs = (TextView)view.findViewById(R.id.remedy_herbs);
                  remedyFoods = (TextView)view.findViewById(R.id.remedy_foods);
                  remedyTable = (TableLayout)view.findViewById(R.id.remedy_table);
  
                  TableRow titleRow = new TableRow(RemedyActivity.this);
                  TextView titleSupplement = new TextView(RemedyActivity.this); 
                  TextView titleDosage = new TextView(RemedyActivity.this);
                  TextView titleComment = new TextView(RemedyActivity.this);
                  titleSupplement.setText("Supplement");
                  titleDosage.setText("Dosage");
                  titleComment.setText("Comment");
                  titleSupplement.setGravity(Gravity.CENTER);
                  titleDosage.setGravity(Gravity.CENTER);
                  titleComment.setGravity(Gravity.CENTER);
                  titleRow.addView(titleSupplement);
                  titleRow.addView(titleDosage);
                  titleRow.addView(titleComment);
                  remedyTable.addView(titleRow);                          
  
                  ((ViewPager) collection).addView(view, 0);
                  return view;
  </code></pre>
  
  <p>Button Click (where rows after title row are deleted and new rows added)</p>
  
  <pre><code>        //Updating Table  
          if(remedyTable.getChildCount()&gt;0){
              for (int i = 0; i &lt; remedyTable.getChildCount(); i++) {
                  if(i&gt;0){
                      remedyTable.removeViewAt(i); //Only removing odd rows, instead off all rows.  Why?
                  }
              }
          }
  
          remedyItemsSupplements = new ArrayList&lt;String&gt;();
          remedyItemsDosage = new ArrayList&lt;String&gt;();
          remedyItemsComments = new ArrayList&lt;String&gt;();
  
          remedyDescription.setText(R.string.acne_description);
          remedyCause.setText(R.string.acne_cause);
          remedyHerbs.setText(R.string.acne_herbs);
          remedyFoods.setText(R.string.acne_foods);
  
          remedyListSupplements = res.getStringArray(R.array.acne_supplements);
          remedyListDosage = res.getStringArray(R.array.acne_dosage);
          remedyListComments = res.getStringArray(R.array.acne_comment);
          Collections.addAll(remedyItemsSupplements, remedyListSupplements);
          Collections.addAll(remedyItemsDosage, remedyListDosage);
          Collections.addAll(remedyItemsComments, remedyListComments);                      
  
          for (int i = 0; i &lt; remedyItemsSupplements.size(); i++) {
              TableRow remedyRow = new TableRow(RemedyActivity.this);
              TextView remedySupplement = new TextView(RemedyActivity.this); 
              TextView remedyDosage = new TextView(RemedyActivity.this);
              TextView remedyComment = new TextView(RemedyActivity.this);
  
              remedySupplement.setText(remedyItemsSupplements.get(i));
              remedyDosage.setText(remedyItemsDosage.get(i));
              remedyComment.setText(remedyItemsComments.get(i));
              remedySupplement.setBackgroundResource(R.drawable.table_background);
              remedyDosage.setBackgroundResource(R.drawable.table_background);
              remedyComment.setBackgroundResource(R.drawable.table_background);
              remedySupplement.setHeight(80);
              remedySupplement.setWidth(500);
              remedyDosage.setHeight(80);
              remedyComment.setHeight(80);
  
              remedyRow.addView(remedySupplement);
              remedyRow.addView(remedyDosage);
              remedyRow.addView(remedyComment);
              remedyTable.addView(remedyRow);
          }
  </code></pre>