當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。