Android: Making a button visible once webview is done scrolling

后端 未结 5 1042
面向向阳花
面向向阳花 2020-12-19 10:18

I have a webview which shows an html file. When the user scrolls to the bottom of this file in webview, I want a button that was previously hidden to show up, which the user

5条回答
  •  一向
    一向 (楼主)
    2020-12-19 10:55

    Loading / Visible button only when webview reached / scrolled to bottom.

    Create JavaScript class :

    public class JavaScriptInterface {
    
      @android.webkit.JavascriptInterface
      public void didScrollToBottom() {
        Log.d(TAG, "Scroll to Bottom");
        myHandler.post(new Runnable() {
          @Override
          public void run() {
             btnAccept.setVisibility(View.VISIBLE);
    
              }
           });
          }
        }
    

    In onCreate() :

    final JavaScriptInterface jsInterface = new JavaScriptInterface();
    myWebView.addJavascriptInterface(jsInterface, "AndroidFunction");
    

提交回复
热议问题