title: Detect end of ScrollView
body: <p>I have an app, that has an Activity that uses a <code>ScrollView</code>. I need to detect when user gets to the bottom of the <code>ScrollView</code>. I did some googleing and I found <a href="http://marteinn.se/blog/android-determinate-when-scrollview-has-reached-the-bottom/">this page</a> where is explained. But, in the example, that guys extends <code>ScrollView</code>. As I said, I need to extend Activity.</p>
  
  <p>So, I said "ok, let's try to make a custom class extending <code>ScrollView</code>, override the <code>onScrollChanged()</code> method, detect the end of the scroll, and act accordingly".</p>
  
  <p>I did, but in this line:</p>
  
  <pre><code>scroll = (ScrollViewExt) findViewById(R.id.scrollView1);
  </code></pre>
  
  <p>it throws a  <code>java.lang.ClassCastException</code>. I changed the <code>&lt;ScrollView&gt;</code> tags in my XML but, obviously, it doesn't work. My questions are: Why, if <code>ScrollViewExt</code> extends <code>ScrollView</code>, throws to my face a <code>ClassCastException</code>? is there any way to detect end of scrolling without messing too much?</p>
  
  <p>Thank you people.</p>
  
  <p>EDIT:
  As promised, here is the piece of my XML that matters:</p>
  
  <pre><code>&lt;ScrollView
          android:id="@+id/scrollView1"
          android:layout_width="match_parent"
          android:layout_height="match_parent" &gt;
  
  
          &lt;WebView
              android:id="@+id/textterms"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:gravity="center_horizontal"
              android:textColor="@android:color/black" /&gt;
  
      &lt;/ScrollView&gt;
  </code></pre>
  
  <p>I changed it from <code>TextView</code> to <code>WebView</code> to be able of justifying the text inside. What i want to achieve is the "Accept button doesn't activate until the terms of the contract are fully read" thing. My extended class is called <code>ScrollViewEx</code>t. If i change the tag <code>ScrollView</code> for <code>ScrollViewExt</code> it throws an</p>
  
  <pre><code>android.view.InflateException: Binary XML file line #44: Error inflating class ScrollViewExt
  </code></pre>
  
  <p>because it doesn't understand the tag <code>ScrollViewEx</code>. I don't think it has a solution...</p>
  
  <p>Thanks for your answers!</p>