安卓:制作一个按钮可见一次的WebView做滚动 [英] Android: Making a button visible once webview is done scrolling

查看:223
本文介绍了安卓:制作一个按钮可见一次的WebView做滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个web视图,显示一个HTML文件。当用户滚动到的WebView该文件的底部,我想有一个按钮,这是previously隐藏展现出来,用户就可以preSS做一些活动而

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 can then press to do some activity

我做的iOS,在这里我只设置委托到ViewController,只是设置按钮,可见类似的东西。我该怎么做在Android上类似的事情?我注意到没有像iOS中的回调方法。

I did something similar in iOS, where I just set the delegate to the ViewController and just set the button as visible. How do I do something similar on Android? I noticed there isn't a callback method like in iOS.

编辑:现在,我有一个活动有两个对象:包含我的文字一个web视图和一个按钮,这是目前可见的。我希望我的活动,收到消息时的WebView文本滚动至底部,并可见按钮

Right now, I have an activity with 2 objects: a webview containing my text, and a button which is currently invisible. I want my activity to receive a message when the webview text scrolls to the bottom, and make the button visible

推荐答案

加载/可见光按钮仅在web视图达/滚动至底部。

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

创建JavaScript类:

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);

          }
       });
      }
    }

在的onCreate():

In onCreate() :

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

这篇关于安卓:制作一个按钮可见一次的WebView做滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆