title: Android TableLayout with pagination: Problem When click the Next/previous TableLayout need to reset
body: <p>I have 2000 records.I want to show list of products in tablelayout.In the fisrst load need to show 50 records.Rest of the records need to show through pagination.</p>
  
  <p>In <code>onCreate()</code> i have done table Layout: Its Dynamic Table contents</p>
  
  <pre><code>   tl = (TableLayout) findViewById(R.id.tableLayout1);
      if(productList.size() &gt;0){
          if(productList.size() &lt; end){
              end = productList.size();
          }
          Log.i("**onCreate**" , end + "--" + initil);
          stk.setText("Stk " + productList.get(0).getAvailableQuantity());
          for (int i = initil; i &lt;end; i++) {
              Log.i("**i**" ,""+ i);
              TableRow tr = new TableRow(this);
              tr.setTag(i);
              TableLayout.LayoutParams tableRowParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT);
              if(i == initil){
                  selectedProductPrice.setText(Double.toString(productList.get(i).getPrice()));
              }
              int leftMargin=10;
              int topMargin=2;
              int rightMargin=10;
              int bottomMargin=2;
  
              tableRowParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
  
              TextView txtCode = new TextView(this);
              txtCode.setTextSize(1, 12);
              createView(tr, txtCode, productList.get(i).getProductCode());
  
              TextView txtDes = new TextView(this);
              txtDes.setTextSize(1, 12);
              createView(tr, txtDes, productList.get(i).getDescription());
  
              EditText txtQty = new EditText(this);
              txtQty.setTextSize(2, 12);
              txtQty.setHeight(4);
              txtQty.setWidth(6);
              txtQty.setId(i);
              txtQty.setFocusable(true);
              txtQty.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
              txtQty.setText("0.00");
              tr.addView(txtQty); 
  
              txtQty.addTextChangedListener(new TextWatcher() {
                  public void afterTextChanged(Editable s) { 
                      Log.v("TAG", "afterTextChanged");
                  }
  
                  public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
                      Log.v("TAG", "beforeTextChanged");
                  }
  
                  public void onTextChanged(CharSequence s, int start, int before, int count) {
                      Log.v("TAG", "onTextChanged");
                  }
              });
  
              if(invPriceEdit.equals("") &amp;&amp; invPriceEdit.equals("1")){
                  EditText txtPrice = new EditText(this);
                  txtPrice.setText(Double.toString(productList.get(i).getPrice()));
                  txtPrice.setTextSize(1, 12);
                  txtPrice.setHeight(3);
                  txtPrice.setWidth(7);
                  tr.addView(txtPrice); 
  
              }else{
                  TextView txtPrice = new TextView(this);
                  txtPrice.setTextSize(1, 12);
                  txtPrice.setText(Double.toString(productList.get(i).getPrice()));
              }
              Log.i("----" , Double.toString(productList.get(i).getPrice()));
              TextView txtVal = new TextView(this);
              txtVal.setTextSize(1, 12);
              createView(tr, txtVal,"0.00");
  
              TextView txtDisVal = new TextView(this);
              txtDisVal.setTextSize(1,12);
              createView(tr, txtDisVal,"0.00");
  
              TextView txtDisQty = new TextView(this);
              txtDisQty.setTextSize(1, 12);
              createView(tr, txtDisQty,"0");
  
              tr.setOnClickListener(new View.OnClickListener(){
                   public void onClick(View view){
                     System.out.println("Row Clicked with tag " + view.getTag()); 
                   }
              });
              tl.addView(tr);
          }
  </code></pre>
  
  <p>And <code>onNextAction()</code> method I did pagination </p>
  
  <pre><code>  public void onNextProductAction(View view) {
      int tmp = productList.size();
      Button next = (Button) findViewById(R.id.next);
      if(end &lt; tmp){
          end = end +10;
          initil = initil +10;
          if(end &gt; tmp ){
              end = productList.size() - initil;
              next.setEnabled(false);
          }
      }else{
          end = productList.size() - initil;
          next.setEnabled(false);
      }
      Log.i("**onNextProductAction**" , "--" + end + "----" + initil);
       }
  </code></pre>
  
  <p>The problem is When I click the next button TableLaout need to reset the contents.</p>
  
  <p>That means I got list of products using <code>productList = getProducts(altSearch,productCate,productGroup,productType);</code> 
  When I parse the initial value &amp; end value, The it will need to laod particular that records;</p>
  
  <p>When I click next option it attached the records with previous records.</p>
  
  <p>I want to show only next available records only.</p>