onScrollListener for WebViewClient Android
<p>I have an Android WebView, and I want to detect scrolls in it to hide a bar I have at the bottom of the screen, but I cannot even seem to detect the scroll listener.</p>

<p>Firstly, this declares my webview</p>

<pre><code>mWebView.setWebViewClient(new myWebViewClient());
</code></pre>

<p>And in my layout I have</p>

<pre><code>&lt;WebView
    android:id="@+id/activity_main_webview"
    android:layout_width="fill_parent"
    android:clickable="false"
    android:layout_height="fill_parent"
    android:layout_alignParentTop="true"
    android:layout_above="@id/buttonBar"
    android:visibility="gone"&gt;
&lt;/WebView&gt;
</code></pre>

<p>And then in here, I presume I should be able to detect on scroll changes, but it doesn't recognise the Override method</p>

<pre><code>public class myWebViewClient extends WebViewClient{
    @Override
    protected void onScrollChanged (int l, int t, int oldl, int oldt){
        String testString = Integer.toString(t);
        Log.d("Testing", testString);
    }
}
</code></pre>

<p>I think it may be to do with that I extend WebViewClient and onScrollChanged isn't valid, but then how would I change this so I am able to detect a scroll within the webview as I wish to hide the button bar at the bottom of the screen when scrolling up and reappear when scrolling down.</p>

<p>Thanks</p>

<p>EDIT</p>

<p>My webview now looks like this:</p>

<pre><code>&lt;test.application.ObservableWebView
    android:id="@+id/scrollableWebview"
    android:layout_width="fill_parent"
    android:clickable="false"
    android:layout_height="fill_parent"
    android:layout_alignParentTop="true"
    android:layout_above="@id/buttonBar"
    android:visibility="gone"/&gt;
</code></pre>

<p>Then I declare it as so, and then in my oncreate I have the following</p>

<pre><code>ObservableWebView mWebView;

mWebView = (ObservableWebView) findViewById(R.id.scrollableWebview);
            mWebView.clearCache(true);
            mWebView.setWebViewClient(new myWebViewClient());
            mWebView.getSettings().setJavaScriptEnabled(true);
            mWebView.loadUrl(currentURL);



            mWebView.setOnScrollChangedCallback(new ObservableWebView.OnScrollChangedCallback(){
                public void onScroll(int l, int t){
                    String testString = Integer.toString(t);
                    Log.d("Testing", testString);
                }
            });


    FATAL EXCEPTION: main
Process: test.application, PID: 5143
java.lang.RuntimeException: Unable to start activity ComponentInfo{test.application/test.application.MainActivity}: android.view.InflateException: Binary XML file line #72: Error inflating class test.application.ObservableWebView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2354)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.access$900(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1322)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5300)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
Caused by: android.view.InflateException: Binary XML file line #72: Error inflating class test.application.ObservableWebView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378)
at android.app.Activity.setContentView(Activity.java:2221)
at test.application.MainActivity.onCreate(MainActivity.java:62)
at android.app.Activity.performCreate(Activity.java:6088)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2416) 
at android.app.ActivityThread.access$900(ActivityThread.java:154) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1322) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5300) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "test.application.ObservableWebView" on path: DexPathList[[zip file "/data/app/test.application-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.view.LayoutInflater.createView(LayoutInflater.java:571)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378) 
at android.app.Activity.setContentView(Activity.java:2221) 
at test.application.MainActivity.onCreate(MainActivity.java:62) 
at android.app.Activity.performCreate(Activity.java:6088) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2416) 
at android.app.ActivityThread.access$900(ActivityThread.java:154) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1322) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5300) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699) 
Suppressed: java.lang.ClassNotFoundException: Didn't find class "test.application.ObservableWebView" on path: DexPathList[[dex file "/data/data/test.application/files/instant-run/dex/slice-support-annotations-24.0.0-alpha1_970e9cd91c4c5137fd4a02c13abfe400ea2225d3-classes.dex", dex file "/data/data/test.application/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/test.application/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/test.application/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/test.application/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/test.application/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/test.application/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/test.application/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/test.application/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/test.application/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/test.application/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/test.application/files/instant-run/dex/slice-internal_impl-24.0.0-alpha1_956ff9371be37fc55e1d852ca9d22c472953ad20-classes.dex", dex file "/data/data/test.application/files/instant-run/dex/slice-com.google.android.gms-play-services-measurement-8.4.0_f4c6c892c1fde4f59a633646b2a693f4e8f51799-classes.dex", dex file "/data/data/test.application/files/instant-run/dex/slice-com.google.android.gms-play-services-basement-8.4.0_38903af7dee8af1f1e19ad
05-17 19:59:34.349 5143-5143/test.application D/AppTracker: App Event: crash
</code></pre>