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


Java View.isClickable方法代码示例

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


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

示例1: withUsageHintOnClick

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

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

示例2: addOnClickListener

import android.view.View; //导入方法依赖的package包/类
/**
 * add childView id
 *
 * @param viewId add the child view id   can support childview click
 * @return if you use adapter bind listener
 * @link {(adapter.setOnItemChildClickListener(listener))}
 * <p>
 * or if you can use  recyclerView.addOnItemTouch(listerer)  wo also support this menthod
 */
@SuppressWarnings("unchecked")
public BaseViewHolder addOnClickListener(@IdRes final int viewId) {
    childClickViewIds.add(viewId);
    final View view = getView(viewId);
    if (view != null) {
        if (!view.isClickable()) {
            view.setClickable(true);
        }
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (adapter.getOnItemChildClickListener() != null) {
                    adapter.getOnItemChildClickListener().onItemChildClick(adapter, v, getClickPosition());
                }
            }
        });
    }

    return this;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:BaseViewHolder.java

示例3: addOnClickListener

import android.view.View; //导入方法依赖的package包/类
/**
 * add childView id
 *
 * @param viewId add the child view id   can support childview click
 * @return if you use adapter bind listener
 * @link {(adapter.setOnItemChildClickListener(listener))}
 * <p>
 * or if you can use  recyclerView.addOnItemTouch(listerer)  wo also support this menthod
 */

public BaseViewHolder addOnClickListener(final int viewId) {
    childClickViewIds.add(viewId);
    final View view = getView(viewId);
    if (!view.isClickable()) {
        view.setClickable(true);
    }
    if (view != null) {
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (adapter.getOnItemChildClickListener() != null) {
                    adapter.getOnItemChildClickListener().onItemChildClick(adapter, v, getClickPosition());
                }
            }
        });
    }

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

示例4: 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

示例5: 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

示例6: setOnItemClickListener

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

示例7: onTouch

import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onTouch(View v, MotionEvent event) {
    KeyboardUtils.hideSoftInput(mContext);
    View currentFocus = mContext.getCurrentFocus();
    //处理列表中的控件需要点击两次才生效的问题
    if (currentFocus != v && v.isClickable() && event.getAction() == MotionEvent.ACTION_DOWN) {
        v.requestFocus();
        return false;
    }
    
    if (currentFocus instanceof EditText) {
        mRootView.requestFocus();
    }
    return false;
}
 
开发者ID:SpannerBear,项目名称:ValueAddSubView,代码行数:16,代码来源:FocusManager.java

示例8: RadiusViewDelegate

import android.view.View; //导入方法依赖的package包/类
public RadiusViewDelegate(View view, Context context, AttributeSet attrs) {
    this.view = view;
    this.mContext = context;
    obtainAttributes(context, attrs);
    view.setSelected(selected);
    if (!(view instanceof CompoundButton) && !view.isClickable()) {
        view.setClickable(isRippleEnable);
    }
}
 
开发者ID:AriesHoo,项目名称:UIWidget,代码行数:10,代码来源:RadiusViewDelegate.java

示例9: avoidDoubleClicks

import android.view.View; //导入方法依赖的package包/类
/***
 * To prevent from double clicking the row item and so prevents overlapping fragment.
 * **/
public static void avoidDoubleClicks(final View view) {
    final long DELAY_IN_MS = 500;
    if (!view.isClickable()) {
        return;
    }
    view.setClickable(false);
    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            view.setClickable(true);
        }
    }, DELAY_IN_MS);
}
 
开发者ID:QuixomTech,项目名称:DeviceInfo,代码行数:17,代码来源:Methods.java

示例10: onInterceptTouchEvent

import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent event) {
    int action = event.getActionMasked();
    boolean isScrollIdle = RecyclerListView.this.getScrollState() == RecyclerListView.SCROLL_STATE_IDLE;

    if ((action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_DOWN) && currentChildView == null && isScrollIdle) {
        currentChildView = view.findChildViewUnder(event.getX(), event.getY());
        if (currentChildView instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) currentChildView;
            float x = event.getX() - currentChildView.getLeft();
            float y = event.getY() - currentChildView.getTop();
            final int count = viewGroup.getChildCount();
            for (int i = count - 1; i >= 0; i--) {
                final View child = viewGroup.getChildAt(i);
                if (x >= child.getLeft() && x <= child.getRight() && y >= child.getTop() && y <= child.getBottom()) {
                    if (child.isClickable()) {
                        currentChildView = null;
                        break;
                    }
                }
            }
        }
        currentChildPosition = -1;
        if (currentChildView != null) {
            currentChildPosition = view.getChildPosition(currentChildView);
            MotionEvent childEvent = MotionEvent.obtain(0, 0, event.getActionMasked(), event.getX() - currentChildView.getLeft(), event.getY() - currentChildView.getTop(), 0);
            if (currentChildView.onTouchEvent(childEvent)) {
                interceptedByChild = true;
            }
            childEvent.recycle();
        }
    }

    if (currentChildView != null && !interceptedByChild) {
        try {
            if (event != null) {
                mGestureDetector.onTouchEvent(event);
            }
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }
    }

    if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_DOWN) {
        if (!interceptedByChild && currentChildView != null) {
            selectChildRunnable = new Runnable() {
                @Override
                public void run() {
                    if (selectChildRunnable != null && currentChildView != null) {
                        currentChildView.setPressed(true);
                        selectChildRunnable = null;
                    }
                }
            };
            AndroidUtilities.runOnUIThread(selectChildRunnable, ViewConfiguration.getTapTimeout());
        }
    } else if (currentChildView != null && (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP || action == MotionEvent.ACTION_CANCEL || !isScrollIdle)) {
        if (selectChildRunnable != null) {
            AndroidUtilities.cancelRunOnUIThread(selectChildRunnable);
            selectChildRunnable = null;
        }
        currentChildView.setPressed(false);
        currentChildView = null;
        interceptedByChild = false;
    }
    return false;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:68,代码来源:RecyclerListView.java


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