当前位置: 首页>>代码示例>>Java>>正文


Java View.isLongClickable方法代码示例

本文整理汇总了Java中android.view.View.isLongClickable方法的典型用法代码示例。如果您正苦于以下问题:Java View.isLongClickable方法的具体用法?Java View.isLongClickable怎么用?Java View.isLongClickable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.isLongClickable方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findClickableViewInChild

import android.view.View; //导入方法依赖的package包/类
private boolean findClickableViewInChild(View view, int x, int y) {
    if (view instanceof ViewGroup) {
        ViewGroup viewGroup = (ViewGroup) view;
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            View child = viewGroup.getChildAt(i);
            final Rect rect = new Rect();
            child.getHitRect(rect);

            final boolean contains = rect.contains(x, y);
            if (contains) {
                return findClickableViewInChild(child, x - rect.left, y - rect.top);
            }
        }
    } else if (view != childView) {
        return (view.isEnabled() && (view.isClickable() || view.isLongClickable() || view.isFocusableInTouchMode()));
    }

    return view.isFocusableInTouchMode();
}
 
开发者ID:yangchong211,项目名称:YCUtils,代码行数:20,代码来源:MaterialRippleLayout.java

示例2: findClickableViewInChild

import android.view.View; //导入方法依赖的package包/类
private boolean findClickableViewInChild(View view, int x, int y) {
    if (view instanceof ViewGroup) {
        ViewGroup viewGroup = (ViewGroup) view;
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            View child = viewGroup.getChildAt(i);
            Rect rect = new Rect();
            child.getHitRect(rect);
            if (rect.contains(x, y)) {
                return findClickableViewInChild(child, x - rect.left, y - rect.top);
            }
        }
    } else if (view != this.childView) {
        return view.isEnabled() && (view.isClickable() || view.isLongClickable() || view.isFocusableInTouchMode());
    }
    return view.isFocusableInTouchMode();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:MaterialRippleLayout.java

示例3: addOnLongClickListener

import android.view.View; //导入方法依赖的package包/类
/**
 * add long click view id
 *
 * @param viewId
 * @return if you use adapter bind listener
 * @link {(adapter.setOnItemChildLongClickListener(listener))}
 * <p>
 * or if you can use  recyclerView.addOnItemTouch(listerer)  wo also support this menthod
 */
@SuppressWarnings("unchecked")
public BaseViewHolder addOnLongClickListener(@IdRes final int viewId) {
    itemChildLongClickViewIds.add(viewId);
    final View view = getView(viewId);
    if (view != null) {
        if (!view.isLongClickable()) {
            view.setLongClickable(true);
        }
        view.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                return adapter.getOnItemChildLongClickListener() != null &&
                        adapter.getOnItemChildLongClickListener().onItemChildLongClick(adapter, v, getClickPosition());
            }
        });
    }
    return this;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:BaseViewHolder.java

示例4: addOnLongClickListener

import android.view.View; //导入方法依赖的package包/类
/**
 * add long click view id
 *
 * @param viewId
 * @return if you use adapter bind listener
 * @link {(adapter.setOnItemChildLongClickListener(listener))}
 * <p>
 * or if you can use  recyclerView.addOnItemTouch(listerer)  wo also support this menthod
 */
public BaseViewHolder addOnLongClickListener(final int viewId) {
    itemChildLongClickViewIds.add(viewId);
    final View view = getView(viewId);
    if (!view.isLongClickable()) {
        view.setLongClickable(true);
    }
    if (view != null) {
        view.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                if (adapter.getmOnItemChildLongClickListener() != null) {
                    adapter.getmOnItemChildLongClickListener().onItemChildLongClick(adapter, v, getClickPosition());
                }
                return false;
            }
        });
    }

    return this;
}
 
开发者ID:liu-xiao-dong,项目名称:JD-Test,代码行数:30,代码来源:BaseViewHolder.java

示例5: withUsageHintOnLongClick

import android.view.View; //导入方法依赖的package包/类
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public static Matcher<? super View> withUsageHintOnLongClick(final Matcher<? extends CharSequence> charSequenceMatcher) {
    return new TypeSafeMatcher<View>() {
        @Override
        protected boolean matchesSafely(View view) {
            if (!view.isLongClickable()) {
                return false;
            }
            AccessibilityNodeInfo.AccessibilityAction clickAction = findAction(view, AccessibilityNodeInfo.ACTION_LONG_CLICK);
            return charSequenceMatcher.matches(clickAction.getLabel());
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("is long clickable and has custom usage hint for ACTION_LONG_CLICK: ");
            charSequenceMatcher.describeTo(description);
        }
    };
}
 
开发者ID:novoda,项目名称:espresso-support,代码行数:20,代码来源:AccessibilityViewMatchers.java

示例6: onLongPress

import android.view.View; //导入方法依赖的package包/类
private void onLongPress() {
    clearCallbacks();
    View src = this.mSrc;
    if (src.isEnabled() && !src.isLongClickable() && onForwardingStarted()) {
        src.getParent().requestDisallowInterceptTouchEvent(true);
        long now = SystemClock.uptimeMillis();
        MotionEvent e = MotionEvent.obtain(now, now, 3, 0.0f, 0.0f, 0);
        src.onTouchEvent(e);
        e.recycle();
        this.mForwarding = true;
        this.mWasLongPress = true;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:ListPopupWindow.java

示例7: onClick

import android.view.View; //导入方法依赖的package包/类
/**
 * Called when a wallpaper tile is clicked
 */
@Override
public void onClick(View v) {
    if (mActionMode != null) {
        // When CAB is up, clicking toggles the item instead
        if (v.isLongClickable()) {
            onLongClick(v);
        }
        return;
    }
    WallpaperTileInfo info = (WallpaperTileInfo) v.getTag();
    if (info.isSelectable() && v.getVisibility() == View.VISIBLE) {
        selectTile(v);
        setWallpaperButtonEnabled(true);
    }
    info.onClick(this);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:20,代码来源:WallpaperPickerActivity.java

示例8: setOnItemLongClickListener

import android.view.View; //导入方法依赖的package包/类
/**
 * 为任意ViewGroup设置OnItemLongClickListener.
 * 该方法必须在addViews()方法之后调用,否则无效。
 * 因为ItemView 必须被添加在ViewGroup里才能遍历到。
 * 建议直接在addViews()方法里传入OnItemLongClickListener进行设置,性能更高
 *
 * @param viewGroup
 * @param onItemLongClickListener
 */
public static void setOnItemLongClickListener(final ViewGroup viewGroup, final OnItemLongClickListener onItemLongClickListener) {
    if (viewGroup == null || onItemLongClickListener == null) {
        return;
    }
    int childCount = viewGroup.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View itemView = viewGroup.getChildAt(i);
        //itemView之前没有长按事件才会去设置
        if (null != itemView && !itemView.isLongClickable()) {
            final int finalI = i;
            itemView.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View view) {
                    return onItemLongClickListener.onItemLongClick(viewGroup, itemView, finalI);
                }
            });
        }
    }
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:29,代码来源:ViewGroupUtils.java


注:本文中的android.view.View.isLongClickable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。