title: Android ScrollView add data on end scroll
body: <p>I've read a lot of posts but never find solution for my problem which is:
  I have LinearLayout inside ScrollView. LinearLayout containt inflated Layout. At the end I have button. When user clicks on the button it inflates more Layouts (adds more table rows). Now, I want to remove the button and call its function when user scrolls to bottom.</p>
  
  <p>--edited--</p>
  
  <p>Here is part of my code...</p>
  
  <pre><code>public void showRows(){
      try {
          mydb = openOrCreateDatabase(DBNAME, Context.MODE_PRIVATE, null);
          Cursor select = mydb.rawQuery("SELECT * from TRANSACTIONS "+
            "limit "+nRow+",20", null);
  
          if (select.moveToFirst()) {
              do {
                  LinearLayout item = (LinearLayout)findViewById(R.id.item);
                  View child = getLayoutInflater().inflate(R.layout.child, null);
                  item.addView(child);
  
                  TextView txt = (TextView) child.findViewById(R.id.txt);
                  txt.setText(select.getString(0));
  
              } while (select.moveToNext());
          }
      } catch (Exception e) {
          Toast.makeText(getApplicationContext(), "Reading error.", Toast.LENGTH_LONG).show();
      } finally {
          mydb.close();
  
          if(nRow+11 &lt;= nTotalRows){
              LinearLayout item = (LinearLayout)findViewById(R.id.item);
              child_more = getLayoutInflater().inflate(R.layout.transaction_more, null);
              item.addView(child_more);
              bMore = (Button) child_more.findViewById(R.id.bMore);
              bMore.setOnClickListener(this);
  
              // on click nRow = nRow + 20 ... and calls again the same function
  
              //TODO...
              //...remove button but call more if ScrollView reachs end...
          }
      }
  
  }
  </code></pre>