【问题标题】:47degrees AndroidSwipeList only receives move events every second touch47degrees AndroidSwipeList 每秒只接收一次移动事件
【发布时间】:2014-05-09 08:02:22
【问题描述】:

我正在使用 47 度 android 滑动列表视图 https://github.com/47deg/android-swipelistview

我将所有文件复制到我的 Eclipse 项目中并没有改变。

我在 xml 中设置了列表视图

<com.company.appname.swipe.SwipeListView
            xmlns:swipe="http://schemas.android.com/apk/res-auto"
            android:id="@+id/home_list_view"
            android:listSelector="#00000000"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            swipe:swipeFrontView="@id/swipelist_frontview"
            swipe:swipeBackView="@id/swipelist_backview"
            swipe:swipeActionLeft="reveal"
            swipe:swipeActionRight="reveal"
            swipe:swipeMode="both"
            swipe:swipeCloseAllItemsWhenMoveList="false"
            swipe:swipeOpenOnLongPress="false"
            swipe:swipeAnimationTime="300"
            swipe:swipeOffsetLeft="100dp"
            swipe:swipeOffsetRight="0dp"
            />

我已经在代码中设置了 SwipeListView

SwipeListViewTouchListener touchListener = new SwipeListViewTouchListener(mListView, R.id.swipelist_frontview, R.id.swipelist_backview);
    touchListener.resetItems();
    mListView.setOnTouchListener(touchListener);

当我尝试滑动列表项时,顶视图开始滑动一秒钟然后停止(平均说 10%,但可能会根据滑动速度略有不同)。所以它被卡在那个位置。我第二次尝试滑动它时,它会平滑滚动。

注意:我每触摸一个项目,它就会暂停一次 - 但它不必是同一个项目。例如,我可以开始滑动将停止的一行,然后我可以滚动同一行或另一行,它会很流畅。

在调查中,我注意到第一次尝试滑动投掷和MotionEvent.ACTION_DOWN 事件,然后是MotionEvent.ACTION_UP 事件。第二次出现MotionEvent.ACTION_DOWN,后面跟着MotionEvent.ACTION_MOVE,后面跟着MotionEvent.ACTION_UP(所以第一次没有MotionEvent.ACTION_MOVE

有什么想法或建议吗?

【问题讨论】:

  • 我没有使用 47degrees AndroidSwipeList,但从 [tutecentral.com/android-swipe-listview/] 实现,这在我的情况下工作正常......看看那个......
  • 我已经在我的项目中加入了 swipe listivew 但我没有任何问题你能发布更多代码
  • 嗨@Dittimon 滚动listView 时如何管理滑动项目?因为在这里我也设置了 swipe:swipeCloseAllItemsWhenMoveList="false" 但在我的情况下,当我滚动 listview swipedlistitem 改变位置时。你是如何管理这个的。有什么方法可以管理这个吗?能否请您发布您的代码...

标签: android motionevent


【解决方案1】:

我在我的项目中使用了滑动列表视图,我没有遇到任何问题。我在您的代码和我的代码中看到的唯一区别是 touchListener.resetItems(); 我使用滑动监听器而不是触摸监听器。

listViewCalendar
            .setSwipeListViewListener(new BaseSwipeListViewListener() {

                @Override
                public void onOpened(int position, boolean toRight) {
                }

                @Override
                public void onClosed(int position, boolean fromRight) {
                }

                @Override
                public void onListChanged() {
                }

                @Override
                public void onMove(int position, float x) {
                }

                @Override
                public void onStartOpen(int position, int action,
                        boolean right) {

                }

                @Override
                public void onStartClose(int position, boolean right) {



                }

                @Override
                public void onClickFrontView(int position) {
                    // 
                }

                @Override
                public void onClickBackView(int position) {
                    // Log.d("swipe", 
                }

                @Override
                public void onDismiss(int[] reverseSortedPositions) {

                }

            });

    listViewCalendar.setOffsetLeft((width - convertDpToPixel(115)));
    listViewCalendar.setSwipeMode(SwipeListView.SWIPE_MODE_LEFT);
    listViewCalendar.setSwipeActionLeft(SwipeListView.SWIPE_ACTION_REVEAL);
    listViewCalendar.setOffsetLeft(width - convertDpToPixel(120f));
    listViewCalendar.setAnimationTime(75);

这是我的 xml。

<com.fortysevendeg.swipelistview.SwipeListView
    xmlns:swipe="http://schemas.android.com/apk/res-auto"
    android:id="@+id/listViewCalendar"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/buttonNewEntry"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/relativeLayout1"
    android:listSelector="#00000000"
    swipe:swipeBackView="@+id/back"
    swipe:swipeCloseAllItemsWhenMoveList="true"
    swipe:swipeFrontView="@+id/front"
    swipe:swipeMode="both" >
</com.fortysevendeg.swipelistview.SwipeListView>

如有任何问题,请随时提出。

【讨论】:

  • Hi @Illegal Argument I am also using com.fortysevendeg.swipelistview.SwipeListView in my project. I am facing one problem when using 47 degree SwipeListView i.e., In my project I don't want to Close swiped items when scrolling listview so for that I set swipe:swipeCloseAllItemsWhenMoveList="false" in my xml. When I used this swiped list item changing position. Ex : If I swipe on 3rd item and I scrolled my listview swiping showing on 5t item so, how to manage this one in my project?
  • @Rajesh SwipeListView 扩展了列表视图,因此它可以重用视图。这意味着如果打开的列表在屏幕边界之外,它将失去其打开状态。您可以将打开位置的状态保存在另一个数组中,并可以在适配器的 getView 方法中以编程方式打开它。如果你问一个新问题会更好
【解决方案2】:

似乎将 listview swipemode 属性更改为

swipe:swipeMode="none"

解决了我的特殊问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多