如何避免在奇巧的android 4.4上长preSS默认选择? [英] How to avoid Default selection on long press in android Kitkat 4.4?

查看:121
本文介绍了如何避免在奇巧的android 4.4上长preSS默认选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好开发商,
                 我与Btwebview这里长preSS的工作,我们避免对长期preSS默认选择功能,并给予我们长期的preSS方法own.The压倒一切的是,直到Android 4.3的,但与4.4 defalut可以正常使用选择还与actionbar.Below未来我正在提样本code -

Hello Developers, i am working with Btwebview here on long press we are avoiding the default selection functionality on long press and giving our own.The overriding of long press method is working perfectly till android 4.3 but with 4.4 the defalut selection also coming with actionbar.Below i am mentioning the sample code-

public class BTWebView extends WebView implements TextSelectionJavascriptInterfaceListener, OnTouchListener, OnLongClickListener,DragListener    {
.......
public BTWebView(Context context) {
        super(context);
        this.ctx = context;
        this.setup(context);
    }
    protected void setup(Context context)
        {
        this.setOnLongClickListener(this);
        this.setOnTouchListener(this);

         }

和长preSS

   @Override
    public boolean onLongClick(View v)
    {
       ......
    return true;  
    }
}

下面因此它避免默认选择,直到4.3重写长按和返回值作为真正经过这么请告诉我如何避免完整的默认选择或至少避免了操作栏亮起长preSS .thanks提前

Here after overriding the long click and return value as true so it avoid default selection till 4.3 so please tell me how to avoid either the complete default selection or atleast avoid the action bar comes on long press .thanks in advance

推荐答案

由拉维赛尼提出的奇巧和上述解决方案的工作,以prevent默认选择界面出现。然而,对于ACTION_UP事件prevents返回true一扔手势垂直滚动迅速的内容,所以使用的WebView似乎不自然。我加的 isInSelectionMode()的条件prevent这一点,现在一扔手势在选择模式下正常工作时除外。从 WebViewMarker GitHub的项目中的code。与我的变化情况如下(以TextSelectionSupport.java模块,onTouch ()方法):

The solution for KitKat and above proposed by Ravi Saini works to prevent the default selection interface to appear. However, return true for ACTION_UP event prevents fling gestures for scrolling the contents vertically quickly, so the use of WebView seems unnatural. I added isInSelectionMode() condition to prevent this, now fling gestures work fine, except when in selection mode. The code from WebViewMarker GitHub project with my change is as follows (in TextSelectionSupport.java module, onTouch() method):

    case MotionEvent.ACTION_UP:
        if (!mScrolling) {
            endSelectionMode();
            //
            // Fixes 4.4 double selection
            // See: http://stackoverflow.com/questions/20391783/how-to-avoid-default-selection-on-long-press-in-android-kitkat-4-4
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                return false;
            }
        }
        mScrollDiffX = 0;
        mScrollDiffY = 0;
        mScrolling = false;
        //
        // Fixes 4.4 double selection
        // See: http://stackoverflow.com/questions/20391783/how-to-avoid-default-selection-on-long-press-in-android-kitkat-4-4
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && isInSelectionMode()) {
            return true;
        }
        break;

格雷格

这篇关于如何避免在奇巧的android 4.4上长preSS默认选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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