Detect end of ScrollView
<p>I have an app, that has an Activity that uses a ScrollView. I need to detect when user gets to the bottom of the ScrollView. I did some googleing and i found <a href="http://www.marteinn.se/blog/?p=485" rel="nofollow" title="this page">this page</a> where is explained. but, in the example, that guys extends ScrollView. As i said, i extend Activity and MUST extend Activity.</p>

<p>So, i said "ok, let's try to make a custom class extending ScrollView, override the onScrollChanged() 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  java.lang.ClassCastException. I changed the  tags in my XML but, obviously, it doesn't work. My questions are: Why, if ScrollViewExt extends ScrollView, throws to my face a ClassCastException? 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 TextView to WebView 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 ScrollViewExt. If i change the tag "ScrollView" for "ScrollViewExt" it throws an "android.view.InflateException: Binary XML file line #44: Error inflating class ScrollViewExt", because it doesn't understands the tag ScrollViewText. I don't think it has a solution...</p>

<p>Thanks for your answers!</p>
