Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make a Scroll Listener for WebView in Android
    primarykey
    data
    text
    <p>How to implement the Scroll Listener for <code>WebView</code> in Android</p> <p>i tried this but its not calling my <code>Log.i</code> on scrolling the webview.</p> <pre><code>package com.example.webview.full.width; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.webkit.WebView; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; public class scorllableWebview extends WebView implements OnScrollListener { Context ctx; AttributeSet atrs; public scorllableWebview(Context context) { super(context); ctx = context; } public scorllableWebview(Context context, AttributeSet atters){ super(context, atters); ctx = context; atrs = atters; } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { Log.i("onScroll", "Called"); } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { Log.i("onScrollStateChanged", "Called"); } } </code></pre> <p>Here is my <code>MainActivity.java</code></p> <pre><code>package com.example.webview.full.width; import android.app.Activity; import android.app.ProgressDialog; import android.os.Bundle; import android.view.Menu; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Toast; public class MainActivity extends Activity { ProgressDialog progressDialog; scorllableWebview wv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); wv = (scorllableWebview) findViewById(R.id.scorllableWebview); wv.getSettings().setJavaScriptEnabled(true); wv.getSettings().setBuiltInZoomControls(true); wv.getSettings().supportZoom(); progressDialog = ProgressDialog.show(MainActivity.this, "Loading Book...!", "Please Wait"); progressDialog.setCancelable(true); String htnlString = "&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;body style = \"text-align:center\"&gt;&lt;script type=\"text/javascript\"&gt;for(a=1;a&lt;=10;a++)document.write('&lt;img style=\"border-style:dotted;border-width:10px;border-color:black;\"src=\"http://myURL.com/books_snaps/EN567/'+a+'.jpg\" alt=\"Page Not Found\"/&gt;');&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;"; // width=\"100%\" wv.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { progressDialog.dismiss(); Toast.makeText(MainActivity.this, "Completed", Toast.LENGTH_SHORT).show(); wv.pageUp(true); super.onPageFinished(view, url); } }); wv.loadDataWithBaseURL(null, htnlString, "text/html", "UTF-8", null); } } </code></pre> <p>and here is my XML file.</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;com.example.webview.full.width.scorllableWebview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scorllableWebview" android:layout_width="match_parent" android:layout_height="match_parent" /&gt; &lt;/RelativeLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload