相关疑难解决方法(0)

检测向上滚动并在ListView中向下滚动

我有以下要求:

  • 首先,从服务器获取页面号:2的数据,并在ListView中填充项目.

考虑到场景中的prev页面和下一页都可用,添加了以下代码:

 if(prevPageNo > 0){
    mListViewActual.setOnScrollListener(this);
 }

 if(nextPageNo > 0){
    mListViewActual.setOnScrollListener(this);
 }
Run Code Online (Sandbox Code Playgroud)

我应该在什么条件下检测向上滚动并向下滚动以下方法:

  1. void onScroll(AbsListView视图,int firstVisibleItem,int visibleItemCount,int totalItemCount)
  2. void onScrollStateChanged(AbsListView视图,int scrollState)

操作之后:检测到向上滚动和向下滚动,因此将使用prev page no或next page no调用服务,以获取要在Listview中填充的项目.

任何输入都会有所帮助.

通过以下链接,但它没有返回正确的向上滚动/向下滚动操作:

链接1 链接2

android scrollbar android-listview

68
推荐指数
7
解决办法
12万
查看次数

onScrollListener的实现,用于检测ListView中滚动的结束

ListView展示了一些物品.我想对当前显示在可见部分的项目执行一些操作ListView,具体取决于ListView滚动的方式; 因此我想要实现OnScrollListenerListView.根据Android api引用,onScroll方法"将在滚动完成后调用".这似乎是我所需要的,因为一旦滚动完成,我就会对其执行操作ListView(onScroll方法返回显示的第一个项目的索引和显示的项目数).

但是一旦实现,我就会看到LogCatonScroll方法不仅在滚动完成后被触发,而且对于从滚动的开始到结束进入显示视图的每个新项目都被触发.这不是我期望的行为,也不是我需要的行为.相反,侦听器的另一个方法(onScrollStateChanged)不提供有关当前显示的项目的信息ListView.

那么,有没有人知道如何使用这两种方法来检测滚动的结尾并获取有关显示项目的信息?api引用与方法的实际行为之间的不一致使我感到困惑.提前致谢.

PS:我已经看到了一些类似的话题,但没有什么能帮助我理解整个事情的运作方式......!

android listview onscroll

42
推荐指数
4
解决办法
7万
查看次数

FloatingActionButton隐藏在列表滚动上

林使用FloatingActionButtonandroid.support.design.widget包:

<android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_marginBottom="20dp"
    android:layout_marginEnd="16dp"
    android:clickable="true"
    android:backgroundTint="@color/primaryColor"
    android:src="@drawable/ic_search_white_24dp"
    app:borderWidth="0dp"
    app:elevation="6dp"
    app:backgroundTint="@color/primaryColorDark"
    app:rippleColor="@color/accentColor" />
Run Code Online (Sandbox Code Playgroud)

当列表视图向下滚动时是否可以将该按钮配置为隐藏动画,并在列表视图滚动到顶部时再次显示该按钮?

android

37
推荐指数
8
解决办法
6万
查看次数

检测适配器中的滚动方向(向上/向下)

我想在我的项目中模仿Google Plus应用程序,因为它现在似乎是参考.

滚动时的列表视图效果非常好,我想做类似的事情.

我已经开始使用LayoutAnimationController http://android-er.blogspot.be/2009/10/listview-and-listactivity-layout.html

LayoutAnimationController controller 
   = AnimationUtils.loadLayoutAnimation(
     this, R.anim.list_layout_controller);
  getListView().setLayoutAnimation(controller);
Run Code Online (Sandbox Code Playgroud)

这似乎很糟糕,因为并非所有元素都是动画的:

所以我最后使用了适配器的getView并使用它:

        AnimationSet set = new AnimationSet(true);

        Animation animation = new AlphaAnimation(0.0f, 1.0f);
        animation.setDuration(800);
        set.addAnimation(animation);

        animation = new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 1.0f,Animation.RELATIVE_TO_SELF, 0.0f
        );
        animation.setDuration(600);
        set.addAnimation(animation);

        row.startAnimation(set);
Run Code Online (Sandbox Code Playgroud)

结果太棒了,我真的很开心!

不幸的是,它只有在我从列表的顶部滚动到底部时才有效!

我想在另一边滚动时使它工作,我需要改变一点TranslateAnimation.

所以我的问题是,有没有办法检测我是否在我的适配器中向上或向下滚动?

animation android listview scroll direction

16
推荐指数
5
解决办法
3万
查看次数