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


Java View.setPressed方法代码示例

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


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

示例1: onKeyUp

import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
	switch (keyCode) {
	case KeyEvent.KEYCODE_DPAD_CENTER:
	case KeyEvent.KEYCODE_ENTER:
		if (!isEnabled()) {
			return true;
		}
		if (isClickable() && isPressed() && mSelectedPosition >= 0
				&& mAdapter != null
				&& mSelectedPosition < mAdapter.getCount()) {

			final View view = getChildAt(mSelectedPosition - mFirstPosition);
			if (view != null) {
				performItemClick(view, mSelectedPosition, mSelectedColId);
				view.setPressed(false);
			}
			setPressed(false);
			return true;
		}
		break;
	}
	return super.onKeyUp(keyCode, event);
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:25,代码来源:AbsHListView.java

示例2: startScrollIfNeeded

import android.view.View; //导入方法依赖的package包/类
private boolean startScrollIfNeeded(int deltaY) {
    // Check if we have moved far enough that it looks more like a
    // scroll than a tap
    final int distance = Math.abs(deltaY);
    int touchSlop = mTouchSlop;
    if (distance > touchSlop) {
        createScrollingCache();
        mTouchMode = TOUCH_MODE_SCROLL;
        mMotionCorrection = deltaY;
        setPressed(false);
        View motionView = getChildAt(mMotionPosition - mFirstPosition);
        if (motionView != null) {
            motionView.setPressed(false);
        }
        reportScrollStateChange(OnScrollListener.SCROLL_STATE_TOUCH_SCROLL);
        // Time to start stealing events! Once we've stolen them, don't let anyone
        // steal from us
        requestDisallowInterceptTouchEvent(true);
        return true;
    }

    return false;
}
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:24,代码来源:PLA_AbsListView.java

示例3: onKeyUp

import android.view.View; //导入方法依赖的package包/类
public boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
        case 23:
        case 66:
            if (!isEnabled()) {
                return true;
            }
            if (isClickable() && isPressed() && this.mSelectedPosition >= 0 && this.mAdapter != null && this.mSelectedPosition < this.mAdapter.getCount()) {
                View view = getChildAt(this.mSelectedPosition - this.mFirstPosition);
                if (view != null) {
                    performItemClick(view, this.mSelectedPosition, this.mSelectedColId);
                    view.setPressed(false);
                }
                setPressed(false);
                return true;
            }
    }
    return super.onKeyUp(keyCode, event);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:20,代码来源:AbsHListView.java

示例4: run

import android.view.View; //导入方法依赖的package包/类
@Override
public void run() {
	if (beginTouchAt == null) {
		// Assuming child that was being long pressed
		// is no longer valid
		return;
	}

	mCheckStates.clear();
	final View child = beginTouchAt.view;
	if (child != null) {
		boolean handled = false;
		// if (!mDataChanged) {
		handled = performLongPress();
		// }
		if (handled) {
			mTouchMode = TOUCH_MODE_REST;

			if (mOnTouchModeChangedListener != null) {
				mOnTouchModeChangedListener
						.onTouchModeChanged(mTouchMode);
			}

			// setPressed(false);
			child.setPressed(false);
		} else {
			mTouchMode = TOUCH_MODE_DONE_WAITING;

			if (mOnTouchModeChangedListener != null) {
				mOnTouchModeChangedListener
						.onTouchModeChanged(mTouchMode);
			}
		}
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:FreeFlowContainer.java

示例5: onShowPress

import android.view.View; //导入方法依赖的package包/类
@Override
public void onShowPress(MotionEvent e) {
    View view = getChildViewUnder(e);
    if (view != null) {
        view.setPressed(true);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:ItemTouchListenerAdapter.java

示例6: onSingleTapUp

import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onSingleTapUp(MotionEvent e) {
    View view = getChildViewUnder(e);
    if (view == null) return false;

    view.setPressed(false);
    int position = shiftAdjustInt(recyclerView.getChildAdapterPosition(view));

    if (position != AdmobAdapter.POSITION_ON_AD) {
        listener.onItemClick(recyclerView, view, position);
    }
    return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:ItemTouchListenerAdapter.java

示例7: keyPressed

import android.view.View; //导入方法依赖的package包/类
protected void keyPressed() {
    if (isEnabled() && isClickable()) {
        Drawable selector = this.mSelector;
        Rect selectorRect = this.mSelectorRect;
        if (selector == null) {
            return;
        }
        if ((isFocused() || touchModeDrawsInPressedState()) && !selectorRect.isEmpty()) {
            View v = getChildAt(this.mSelectedPosition - this.mFirstPosition);
            if (v != null) {
                if (!v.hasFocusable()) {
                    v.setPressed(true);
                } else {
                    return;
                }
            }
            setPressed(true);
            boolean longClickable = isLongClickable();
            Drawable d = selector.getCurrent();
            if (d != null && (d instanceof TransitionDrawable)) {
                if (longClickable) {
                    ((TransitionDrawable) d).startTransition(ViewConfiguration.getLongPressTimeout());
                } else {
                    ((TransitionDrawable) d).resetTransition();
                }
            }
            if (longClickable && !this.mDataChanged) {
                if (this.mPendingCheckForKeyLongPress == null) {
                    this.mPendingCheckForKeyLongPress = new CheckForKeyLongPress(this, null);
                }
                this.mPendingCheckForKeyLongPress.rememberWindowAttachCount();
                postDelayed(this.mPendingCheckForKeyLongPress, (long) ViewConfiguration.getLongPressTimeout());
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:37,代码来源:AbsHListView.java

示例8: recycle

import android.view.View; //导入方法依赖的package包/类
/**
 * Recycle cell. This method should be called from getView in Adapter when use SWIPE_ACTION_CHOICE
 *
 * @param convertView parent view
 * @param position    position in list
 */
public void recycle(View convertView, int position) {
    touchListener.reloadChoiceStateInView(convertView.findViewById(swipeFrontView), position);
    touchListener.reloadSwipeStateInView(convertView.findViewById(swipeFrontView), position);

    // Clean pressed state (if dismiss is fire from a cell, to this cell, with a press drawable, in a swipelistview
    // when this cell will be recycle it will still have his pressed state. This ensure the pressed state is
    // cleaned.
    for (int j = 0; j < ((ViewGroup) convertView).getChildCount(); ++j) {
        View nextChild = ((ViewGroup) convertView).getChildAt(j);
        nextChild.setPressed(false);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:SwipeListView.java

示例9: setPressedItem

import android.view.View; //导入方法依赖的package包/类
private void setPressedItem(View child, int position, float x, float y) {
    this.mDrawsInPressedState = true;
    if (VERSION.SDK_INT >= 21) {
        drawableHotspotChanged(x, y);
    }
    if (!isPressed()) {
        setPressed(true);
    }
    layoutChildren();
    if (this.mMotionPosition != -1) {
        View motionView = getChildAt(this.mMotionPosition - getFirstVisiblePosition());
        if (!(motionView == null || motionView == child || !motionView.isPressed())) {
            motionView.setPressed(false);
        }
    }
    this.mMotionPosition = position;
    float childX = x - ((float) child.getLeft());
    float childY = y - ((float) child.getTop());
    if (VERSION.SDK_INT >= 21) {
        child.drawableHotspotChanged(childX, childY);
    }
    if (!child.isPressed()) {
        child.setPressed(true);
    }
    positionSelectorLikeTouchCompat(position, child, x, y);
    setSelectorEnabled(false);
    refreshDrawableState();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:29,代码来源:ListPopupWindow.java

示例10: updateMenuView

import android.view.View; //导入方法依赖的package包/类
public void updateMenuView(boolean cleared) {
    ViewGroup parent = this.mMenuView;
    if (parent != null) {
        int childIndex = 0;
        if (this.mMenu != null) {
            this.mMenu.flagActionItems();
            ArrayList<MenuItemImpl> visibleItems = this.mMenu.getVisibleItems();
            int itemCount = visibleItems.size();
            for (int i = 0; i < itemCount; i++) {
                MenuItemImpl item = (MenuItemImpl) visibleItems.get(i);
                if (shouldIncludeItem(childIndex, item)) {
                    View convertView = parent.getChildAt(childIndex);
                    MenuItemImpl oldItem = convertView instanceof ItemView ? ((ItemView) convertView).getItemData() : null;
                    View itemView = getItemView(item, convertView, parent);
                    if (item != oldItem) {
                        itemView.setPressed(false);
                        ViewCompat.jumpDrawablesToCurrentState(itemView);
                    }
                    if (itemView != convertView) {
                        addItemView(itemView, childIndex);
                    }
                    childIndex++;
                }
            }
        }
        while (childIndex < parent.getChildCount()) {
            if (!filterLeftoverView(parent, childIndex)) {
                childIndex++;
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:33,代码来源:BaseMenuPresenter.java

示例11: clearPressedItem

import android.view.View; //导入方法依赖的package包/类
private void clearPressedItem() {
    this.mDrawsInPressedState = false;
    setPressed(false);
    drawableStateChanged();
    View motionView = getChildAt(this.mMotionPosition - getFirstVisiblePosition());
    if (motionView != null) {
        motionView.setPressed(false);
    }
    if (this.mClickAnimation != null) {
        this.mClickAnimation.cancel();
        this.mClickAnimation = null;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:ListPopupWindow.java

示例12: getViewBitmap

import android.view.View; //导入方法依赖的package包/类
private Bitmap getViewBitmap(View v) {
    v.clearFocus();
    v.setPressed(false);

    boolean willNotCache = v.willNotCacheDrawing();
    v.setWillNotCacheDrawing(false);

    int color = v.getDrawingCacheBackgroundColor();
    v.setDrawingCacheBackgroundColor(0);

    if (color != 0) {
        v.destroyDrawingCache();
    }
    v.buildDrawingCache();
    Bitmap cacheBitmap = v.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }

    Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);

    v.destroyDrawingCache();
    v.setWillNotCacheDrawing(willNotCache);
    v.setDrawingCacheBackgroundColor(color);

    return bitmap;
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:28,代码来源:DragDropHelper.java

示例13: getBitmapFromView2

import android.view.View; //导入方法依赖的package包/类
/**
 * 把一个View的对象转换成bitmap
 *
 * @param view View
 * @return Bitmap
 */
public static Bitmap getBitmapFromView2(View view) {
    if (view == null) {
        return null;
    }
    view.clearFocus();
    view.setPressed(false);

    // 能画缓存就返回false
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(0);
    if (color != 0) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        XPrintUtils.e( "failed getViewBitmap(" + view + ") -->"+
                    new RuntimeException());
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);
    // Restore the view
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
开发者ID:youth5201314,项目名称:XFrame,代码行数:36,代码来源:XBitmapUtils.java

示例14: toBitmap

import android.view.View; //导入方法依赖的package包/类
/**
 * 把view转化为bitmap(截图)
 * 参见:http://www.cnblogs.com/lee0oo0/p/3355468.html
 */
public static Bitmap toBitmap(View view) {
    int width = view.getWidth();
    int height = view.getHeight();
    if (view instanceof ListView) {
        height = 0;
        // 获取listView实际高度
        ListView listView = (ListView) view;
        for (int i = 0; i < listView.getChildCount(); i++) {
            height += listView.getChildAt(i).getHeight();
        }
    } else if (view instanceof ScrollView) {
        height = 0;
        // 获取scrollView实际高度
        ScrollView scrollView = (ScrollView) view;
        for (int i = 0; i < scrollView.getChildCount(); i++) {
            height += scrollView.getChildAt(i).getHeight();
        }
    }
    view.setDrawingCacheEnabled(true);
    view.clearFocus();
    view.setPressed(false);
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    // Reset the drawing cache background color to fully transparent for the duration of this operation
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(Color.WHITE);//截图去黑色背景(透明像素)
    if (color != Color.WHITE) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(cacheBitmap, 0, 0, null);
    canvas.save(Canvas.ALL_SAVE_FLAG);
    canvas.restore();
    if (!bitmap.isRecycled()) {
        LogUtils.verbose("recycle bitmap: " + bitmap.toString());
        bitmap.recycle();
    }
    // Restore the view
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:54,代码来源:ConvertUtils.java

示例15: onTouch

import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onTouch(View v, MotionEvent event) {
    // 做初始化
    if (mTouchSlop == 0) {
        final ViewConfiguration configuration = ViewConfiguration.get(v
                .getContext());
        mTouchSlop = configuration.getScaledTouchSlop();
        parentViewHeight = ((View) (v.getParent())).getHeight();
        parentViewWidth = ((View) (v.getParent())).getWidth();
        ((View) (v.getParent())).getGlobalVisibleRect(parentLoction);

        ViewGroup.LayoutParams layoutParams = v.getLayoutParams();
        if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
            ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) layoutParams;
            leftMargin = params.leftMargin;
            topMargin = params.topMargin;
            rightMargin = params.rightMargin;
            bottomMargin = params.bottomMargin;
        }

    }

    int action = event.getAction();
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            isDrag = false;
            (v.getParent()).requestDisallowInterceptTouchEvent(true);
            lastPosX = (int) event.getX();
            lastPosY = (int) event.getY();
            break;
        case MotionEvent.ACTION_MOVE:
            if (Math.abs(event.getX() - lastPosX) > mTouchSlop
                    || Math.abs(event.getY() - lastPosY) > mTouchSlop) {
                isDrag = true;
            }
            if (isDrag) {
                int posX = (int) event.getRawX();
                int posY = (int) event.getRawY();
                int rParentX = posX - parentLoction.left;
                int rParentY = posY - parentLoction.top;
                int width = v.getWidth();
                int height = v.getHeight();
                int translateY = rParentY - height / 2;
                int translateX = rParentX - width / 2;
                int curTranslateX = translateX - v.getLeft() - leftMargin - mAdjuster.left;
                v.setTranslationX(curTranslateX);
                int curTranslateY = translateY - v.getTop() - topMargin/* - mAdjuster.top*/;
                if (curTranslateY + v.getHeight() + v.getTop() + bottomMargin/* + mAdjuster.bottom */> parentViewHeight) {
                    curTranslateY = parentViewHeight - v.getHeight()
                            - v.getTop() - bottomMargin/* - mAdjuster.bottom*/;
                }
                if (curTranslateY + v.getTop() - topMargin/* - mAdjuster.top*/ < 0) {
                    curTranslateY = -v.getTop() + topMargin/* + mAdjuster.top*/;
                }
                v.setTranslationY(curTranslateY);
            }
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            doPullOverAnimation(v);
            (v.getParent()).requestDisallowInterceptTouchEvent(false);
            v.setPressed(false);
            break;
    }
    return isDrag;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:67,代码来源:FloatLayoutHelper.java


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