當前位置: 首頁>>代碼示例>>Java>>正文


Java GestureDetectorCompat.setIsLongpressEnabled方法代碼示例

本文整理匯總了Java中android.support.v4.view.GestureDetectorCompat.setIsLongpressEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java GestureDetectorCompat.setIsLongpressEnabled方法的具體用法?Java GestureDetectorCompat.setIsLongpressEnabled怎麽用?Java GestureDetectorCompat.setIsLongpressEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.view.GestureDetectorCompat的用法示例。


在下文中一共展示了GestureDetectorCompat.setIsLongpressEnabled方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: DraggableSquareView

import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
public DraggableSquareView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mDragHelper = ViewDragHelper
            .create(this, 10f, new DragHelperCallback());
    moveDetector = new GestureDetectorCompat(context,
            new MoveDetector());
    moveDetector.setIsLongpressEnabled(false); // 不能處理長按事件,否則違背最初設計的初衷
    spaceInterval = (int) getResources().getDimension(R.dimen.drag_square_interval); // 小方塊之間的間隔

    // 滑動的距離閾值由係統提供
    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();

    anchorHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (draggingView != null) {
                // 開始移動重心的動畫
                draggingView.startAnchorAnimation();
            }
        }
    };
}
 
開發者ID:funnyzhaov,項目名稱:Tribe,代碼行數:24,代碼來源:DraggableSquareView.java

示例2: DragLayout

import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
public DragLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.app, 0, 0);
    bottomDragVisibleHeight = (int) a.getDimension(R.styleable.app_bottomDragVisibleHeight, 0);
    bototmExtraIndicatorHeight = (int) a.getDimension(R.styleable.app_bototmExtraIndicatorHeight, 0);
    a.recycle();

    mDragHelper = ViewDragHelper
            .create(this, 10f, new DragHelperCallback());
    mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_TOP);
    moveDetector = new GestureDetectorCompat(context, new MoveDetector());
    moveDetector.setIsLongpressEnabled(false); // 不處理長按事件

    // 滑動的距離閾值由係統提供
    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:DragLayout.java

示例3: init

import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
private void init(Context context, @Nullable AttributeSet attrs, int defStyle) {
    Drawable icon = null;
    String label = null;

    if (attrs != null) {
        // Load attributes
        final TypedArray a = getContext().obtainStyledAttributes(
                attrs, R.styleable.UserInputView, defStyle, 0);
        try {
            icon = a.getDrawable(R.styleable.ShortcutView_shortcutIcon);
            label = a.getString(R.styleable.ShortcutView_shortcutLabel);
        } finally {
            a.recycle();
        }
    }

    LayoutInflater.from(context).inflate(R.layout.view_shortcut, this);
    detector = new GestureDetectorCompat(context, new ShortcutView.InputGestureListener());
    detector.setIsLongpressEnabled(true);


    labelText = findViewById(R.id.shortcut_label);
    setLabel(label);

    iconButton = findViewById(R.id.shortcut_icon);
    if (icon != null) {
        setIcon(icon);
    }
    iconButton.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            return detector.onTouchEvent(motionEvent);
        }
    });
}
 
開發者ID:RawLauncher,項目名稱:RawLauncher,代碼行數:36,代碼來源:ShortcutView.java

示例4: StatsBarGraph

import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
public StatsBarGraph(Context context) {
    super(context, "");

    int width = LayoutParams.MATCH_PARENT;
    int height = getResources().getDimensionPixelSize(R.dimen.stats_barchart_height);
    setLayoutParams(new LayoutParams(width, height));

    setProperties();

    // Use Open Sans
    paint.setTypeface(TypefaceCache.getTypeface(getContext()));

    mDetector = new GestureDetectorCompat(getContext(), new MyGestureListener());
    mDetector.setIsLongpressEnabled(false);
}
 
開發者ID:ldsddn,項目名稱:wordpress_app_android,代碼行數:16,代碼來源:StatsBarGraph.java

示例5: onCreate

import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gestures_demo);
    gestureTypeTV = (TextView) findViewById(R.id.gesture_type_text_view);
    scaleFactorTV = (TextView) findViewById(R.id.scale_factor_text_view);
    textView3 = (TextView) findViewById(R.id.text_view3);
    textView4 = (TextView) findViewById(R.id.text_view4);
    textView5 = (TextView) findViewById(R.id.text_view5);
    gestureDetect = new GestureDetectorCompat(this, this);
    gestureDetect.setIsLongpressEnabled(true);
    scaleDetector = new ScaleGestureDetector(this, new MyScaleListener());
}
 
開發者ID:selendroid,項目名稱:selendroid,代碼行數:14,代碼來源:TouchGesturesActivity.java

示例6: ScrollHelper

import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
ScrollHelper(Context context) {
    mGestureDetectorCompat = new GestureDetectorCompat(context, this);
    mGestureDetectorCompat.setIsLongpressEnabled(true);
}
 
開發者ID:Cleveroad,項目名稱:AdaptiveTableLayout,代碼行數:5,代碼來源:ScrollHelper.java

示例7: initView

import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
private void initView(Context context) {
    mScroller = new OverScroller(context);
    mGesture = new GestureDetectorCompat(context, this);
    mGesture.setIsLongpressEnabled(false);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:7,代碼來源:RefreshLayout.java

示例8: init

import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
/**
 * Initialize all gesture detectors
 * @param context instance of context
 */
private void init(@NonNull final Context context, @NonNull AttributeSet attrs) {
    scaleGestureDetector = new ScaleGestureDetector(context, new ScaleGestureDetector.SimpleOnScaleGestureListener() {

        @Override
        public boolean onScale(ScaleGestureDetector detector) {
            float newScaleFactor = scaleFactor * detector.getScaleFactor();
            newScaleFactor = Math.max(1f, Math.min(newScaleFactor, 3.0f));
            if (Float.compare(scaleFactor, newScaleFactor) == 0)
                return true;
            scaleFactor = newScaleFactor;
            container.setScaleX(scaleFactor);
            container.setScaleY(scaleFactor);
            ViewGroup.LayoutParams params = container.getLayoutParams();
            params.width = (int) (initWidth * scaleFactor);
            params.height = (int) (initHeight * scaleFactor);
            container.setLayoutParams(params);
            if (onScaleListener != null)
                onScaleListener.onScaled(scaleFactor);
            return true;
        }
    });
    rotationGestureDetector = new RotationGestureDetector(new RotationGestureDetector.OnRotationGestureListener() {
        @Override
        public void onRotation(RotationGestureDetector rotationDetector) {
            degrees -= rotationDetector.getAngle();
            setRotation(degrees);
        }
    });
    gestureDetectorCompat = new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public void onLongPress(MotionEvent e) {
            ClipData data = ClipData.newPlainText("", "");
            DragShadowBuilder shadowBuilder = new CustomDragShadowBuilder(ResizeRotationView.this);
            startDrag(data, shadowBuilder, ResizeRotationView.this, 0);
            setVisibility(View.INVISIBLE);
        }
    });
    gestureDetectorCompat.setIsLongpressEnabled(true);
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.ResizeRotationView);
    try {
        lineColor = array.getColor(R.styleable.ResizeRotationView_line_color, DEFAULT_COLOR);
        int drawableId = array.getResourceId(R.styleable.ResizeRotationView_dot_drawable, 0);
        if (drawableId == 0)
            dotDrawable = new ColorDrawable(DEFAULT_COLOR);
        else
            dotDrawable = getResources().getDrawable(drawableId);
    } finally {
        array.recycle();
    }
}
 
開發者ID:Iojjj,項目名稱:AndroidBootstrap,代碼行數:55,代碼來源:ResizeRotationView.java

示例9: setupInteractions

import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
private void setupInteractions(Context context) {

        mScaleGestureDetector = new ScaleGestureDetector(context, mScaleGestureListener);
        mGestureDetector = new GestureDetectorCompat(context, mGestureListener);

        mGestureDetector.setIsLongpressEnabled(false);

        mScroller = new OverScroller(context);
        mZoomer = new Zoomer(context);
    }
 
開發者ID:donglua,項目名稱:JZAndroidChart,代碼行數:11,代碼來源:Chart.java


注:本文中的android.support.v4.view.GestureDetectorCompat.setIsLongpressEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。