标签: onfling

将Fling Gesture添加到图像视图 - Android

好的,我在这里引用了代码:在网格布局上进行手势检测

但是无法让它发挥作用.在我的主要活动中,我定义了一个简单的图像.我想检测一下图像上的闪光.这是我的代码如下.底部的onclick方法为空.是因为这个吗?我把它留空了,因为在其他代码示例中它不是我想要的.我只想要一个简单的吐司,弹出正确的方向或向前扔.

public class GestureRightLeft extends Activity implements OnClickListener  {

    ImageView peek;

    private static final int SWIPE_MIN_DISTANCE = 120;
    private static final int SWIPE_MAX_OFF_PATH = 250;
    private static final int SWIPE_THRESHOLD_VELOCITY = 200;
    private GestureDetector gestureDetector;
    View.OnTouchListener gestureListener;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        peek =(ImageView) findViewById(R.id.peek);
        peek.setImageResource(R.drawable.bluestrip);

        gestureDetector = new GestureDetector(new MyGestureDetector());
        gestureListener = new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        };
    }

    class …
Run Code Online (Sandbox Code Playgroud)

android gestures imageview onfling

48
推荐指数
4
解决办法
8万
查看次数

Android:基于速度的ViewPager滚动

ViewPager现在滚动的方式是每个手势一个项目.无论是全屏快速拖动还是慢速拖动,它都以同样的方式对待投掷手势; 在结束页面只前进一步.

是否有任何项目或示例可以添加基于速度的投掷,根据现有投掷的速度滚动多个项目(如果它仍在进行中)并且如果投掷手势宽而快,则进一步滚动?

如果没有从哪里开始这样的事情?

PS提供赏金.请不要回答对Gallery或Horizo​​ntalScrollView的引用

android gestures onfling android-viewpager

43
推荐指数
1
解决办法
1万
查看次数

Android"刷卡"与"抢购"

在Android开发者手势设计部分中,使用术语"滑动".
开发人员部分中,使用术语"fling".

这些术语是同义词吗?从我发现的情况来看,我相信它们是,但无论是哪种方式都明确地说过.

这就是说,如果我想为实现功能"刷卡",我应该实现onFlingGestureDetector

android gestures swipe onfling

33
推荐指数
2
解决办法
2万
查看次数

Android - 特定视图上的手势检测(向上/向下滑动)

我正在尝试在Android中实现OnGestureListener.
我的布局中有三个TextView.
我想要实现的是为两个textView设置Gesture Listener.
这是布局 -

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rlMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<TextView
    android:id="@+id/tvOne"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="10dp"
    android:layout_marginTop="5dp"
    android:gravity="center"
    android:text="One" />

<TextView
    android:id="@+id/tvTwo"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/tvOne"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="10dp"
    android:layout_marginTop="5dp"
    android:gravity="center"
    android:text="Two" />

<TextView
    android:id="@+id/tvThree"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/tvTwo"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="10dp"
    android:layout_marginTop="5dp"
    android:gravity="center"
    android:text="Three" />
Run Code Online (Sandbox Code Playgroud)

这是活动 -

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;

public class TimeActivity extends Activity implements OnGestureListener {

GestureDetector gestureScanner;

@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.wheelview);
    gestureScanner …
Run Code Online (Sandbox Code Playgroud)

android gesture-recognition swipe onfling

24
推荐指数
2
解决办法
4万
查看次数

在滚动的中间停止scrollView

我有一个包含大量内容的滚动视图.现在,当用户进行投掷或向下滚动时,我希望滚动视图停在特定的视图位置,我正在做一些动画,然后用户可以再次投掷或向下滚动.

我已尝试禁用此处提到的scrollview 但它只在scrollview完全停止并且无法在fling中间停止时禁用.

有什么办法可以在达到某个视图位置或某个y值时停止滚动视图的投掷?

android scrollview onscroll onfling

11
推荐指数
2
解决办法
1万
查看次数

Android OnGestureListener Fling未检测到

我想检测屏幕块中的投掷动作.我正在使用以下代码.

public class MyinfoActivity extends Activity implements OnGestureListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        ..........
        ..........
        gestureScanner = new GestureDetector(this);
        resBlock = (TableRow) findViewById(R.id.ResBlock);
        gestureScanner = new GestureDetector(this);
    }

    @Override
    public boolean onTouchEvent(MotionEvent me){
        Log.d(null,"Touch");
        if (gestureScanner.onTouchEvent(me))
            return gestureScanner.onTouchEvent(me);
        else
            return false;
    }

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2,
                       float velocityX, float velocityY) {
        Log.d(null,"Fling");
        ............
        ............
    }

    @Override
    public boolean onDown(MotionEvent arg0) {
        return false;
    }

    @Override
    public void onLongPress(MotionEvent e) {}

    @Override
    public boolean onScroll(MotionEvent e1, …
Run Code Online (Sandbox Code Playgroud)

android gesture touch-event onfling

10
推荐指数
1
解决办法
1万
查看次数

onfling()由于某种原因没有被调用

我正在尝试在我的应用程序中实现手势,由于某种原因,没有调用onfling().我尝试阅读关于此的大量帖子,并尝试修复我的代码,但它无法正常工作.以下是我的代码.请看一看:

public class MainMenuSlider extends Activity implements OnClickListener{

protected MyGestureListener myGestureListener;

private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;

private ViewFlipper vf;
private Animation animFlipInNext,animFlipOutNext, animFlipInPrevious, animFlipOutPrevious;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.mainmenuslider);
    myGestureListener = new MyGestureListener(this);

    //vf for viewflipper
    vf=(ViewFlipper)findViewById(R.id.ViewFlipper01);
    animFlipInNext = AnimationUtils.loadAnimation(this, R.anim.flipinnext);
    animFlipOutNext = AnimationUtils.loadAnimation(this, R.anim.flipoutnext);
    animFlipInPrevious = AnimationUtils.loadAnimation(this, R.anim.flipinprevious);
    animFlipOutPrevious = AnimationUtils.loadAnimation(this, R.anim.flipoutprevious);

    imageone = (ImageView) findViewById(R.id.imageone);
    imagetwo = (ImageView) findViewById(R.id.imagetwo);
    imageone.setOnClickListener(myGestureListener); …
Run Code Online (Sandbox Code Playgroud)

android gesture onfling

10
推荐指数
1
解决办法
8099
查看次数

检测ScrollView上的结束

我已经覆盖ScrollView了将MotionEvents 传递给a GestureDetector来检测ScrollView上的fling事件.我需要能够检测到滚动停止的时间.这与MotionEvent.ACTION_UP事件不一致,因为这通常发生在fling手势的开始,随后onScrollChanged()是ScrollView上的一连串调用.

所以基本上我们在这里处理的是以下事件:

  1. onFling
  2. onScrollChanged,onScrollChanged,onScrollChanged,...,onScrollChanged

触发onScrollChanged事件时没有回调.我正在考虑使用HandleronFling期间向事件队列发送消息并等待Runnable执行以指示fling 结束,不幸的是它在第一次onScrollChanged调用之后触发.

还有其他想法吗?

android onfling android-scrollview

10
推荐指数
1
解决办法
6551
查看次数

将GestureDetector设置为所有子视图

我想将GestureDetector添加到活动的所有视图(视图组),而不是手动将其分配给每个视图.现在onFling()仅在向后滑动时激活,但在滑动例如button1时不激活.

package com.app.example;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.LinearLayout;

public class ExampleActivity extends Activity {
    Context mContext = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = this;

        LinearLayout parent = new LinearLayout(mContext);
        parent.setOrientation(LinearLayout.VERTICAL);
        parent.setBackgroundColor(Color.RED);

        Button button1 = new Button(mContext);
        button1.setText("Button 1");
        Button button2 = new Button(mContext);
        button2.setText("Button 2");

        parent.addView(button1);
        parent.addView(button2);

        final GestureDetector gestureDetector = new GestureDetector(
                new MyGestureDetector());

        parent.setOnTouchListener(new OnTouchListener() …
Run Code Online (Sandbox Code Playgroud)

android onfling gesturedetector viewgroup

9
推荐指数
1
解决办法
8245
查看次数

在ListView中OnFling,获取刷过的项目信息

我想在我的应用程序中使用本机联系人应用程序的相同行为.具体来说,我想实现向右滑动以及为textmsg向左滑动.我有一个ListView,我设置了arrayAdapter,i'va为onFlingMethod实现了手势检测器.我正确拦截滑动侧,我可以使用Call应用程序.我需要将项目编号(和其他信息)放入Intent,所以我需要获取刷卡项目.在这里我的代码.

public class Contacts extends Activity implements OnGestureListener {

    private static final String TAG = "[Contacts]";
    ArrayList < ContactInfo > mData;

    private static final int SWIPE_MIN_DISTANCE = 120;
    private static final int SWIPE_MAX_OFF_PATH = 250;
    private static final int SWIPE_THRESHOLD_VELOCITY = 200;

    /** Called when the activity is first created. */
    private GestureDetector detector = new GestureDetector(this);
    Button btnContacts;
    Button btnProfile;
    Button btnSettings;
    ImageButton btnStatus;
    HandleServer cubeServer;
    Button slideHandleButton;
    SlidingDrawer slidingDrawer;
    String filter = "n";
    ArrayAdapter < ContactInfo > adapter; …
Run Code Online (Sandbox Code Playgroud)

android listview swipe onfling

8
推荐指数
1
解决办法
9310
查看次数