本文整理汇总了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();
}
}
};
}
示例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();
}
示例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);
}
});
}
示例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);
}
示例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());
}
示例6: ScrollHelper
import android.support.v4.view.GestureDetectorCompat; //导入方法依赖的package包/类
ScrollHelper(Context context) {
mGestureDetectorCompat = new GestureDetectorCompat(context, this);
mGestureDetectorCompat.setIsLongpressEnabled(true);
}
示例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();
}
示例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();
}
}
示例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);
}