本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
};
}
示例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;
}
}
示例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);
}
示例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);
}
});
}
}
}