安卓的WebView的onClick不行

安卓的WebView的onClick不行

本文介绍了安卓的WebView的onClick不行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要隐藏和显示布局的onclick web视图的。

I going to hide and show the Layout onclick of the webview.

我有code象下面这样:

I have code like below:

@Override
public void onClick(View v) {
    switch(v.getId()){
    case R.id.backButton:
        finish();
        break;
    case R.id.webView:
        if(bottomShow){
            bottomLayout.setVisibility(View.GONE);
            bottomShow = false;
        }
        else{
            bottomLayout.setVisibility(View.VISIBLE);
            bottomShow = true;
        }

        break;
    }
}

我还设置clickListener像

I have also set the clickListener as like

webView.setOnClickListener(this);

但即使这样做,我没有得到任何效果。

but even after doing that i am not getting any effect.

为什么我不能够获得点击的WebView ??

Why i am not able to get action on click on the webview ??

Somehelp后,我有尝试onTouchListener象下面这样:

After Somehelp i have try it onTouchListener like below:

@Override
public boolean onTouch(View v, MotionEvent event) {
    switch(v.getId()){
        case R.id.webView:
            if(event.getAction() == MotionEvent.ACTION_UP){
                //Toast.makeText(getApplicationContext(), "Hello", Toast.LENGTH_SHORT).show();
                if(bottomShow){
                    bottomLayout.setVisibility(View.GONE);
                    bottomShow = false;
                }
                else{
                    bottomLayout.setVisibility(View.VISIBLE);
                    bottomShow = true;
                }
                return true;
            }

            break;
    }
    return false;
}

现在它的工作原理,但Webview是无法流畅滚动,因为它之前一样。

Now it works but webView is not smoothly scrolling as it does before.

因此​​,whats为妥善解决?或什么是错在我的code,如果它是??

So whats the proper solution for that ? or whats wrong in my code if it is ??

请帮我。

感谢。

推荐答案

尝试用网页视图的OnTouchListener

Try with OnTouchListener of Webview

这篇关于安卓的WebView的onClick不行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 13:35