如何使列表视图滚动一行在同一时间 [英] How to make List view scroll one row at a time

查看:103
本文介绍了如何使列表视图滚动一行在同一时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是自定义的列表视图通过扩展 BaseAdapter 。每一行都有一个形象,占据列表视图高度的50%,这就是我的方式在同一时间列表视图显示两行。
我想,当我滚动慢或快,无论多么慢或快,列表视图滚动应该只有一个项目,不应该显示排半...

I'm using a custom listview by extending BaseAdapter. Each row has one image and occupies 50% of the listview height, thats way my listview at a time shows two rows. What I want is, when I scroll slow or fast, no matter how slow or fast, the list view should scroll only one item and should not display a half row...

我试过是使用 smoothScrollTo(INT),但它并没有解决我的问题。随着平滑滚动它仍然会混蛋。

What I tried was to use smoothScrollTo(int) but it did not solve my problem. With smooth scrolling it will still jerk.

我的目标SDK版本为7。

My target sdk version is 7.

推荐答案

有关去一点一点:

mList.setOnScrollListener(new OnScrollListener() {
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {}

        public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) 
            {                   
                mList.getRefreshableView().setSelection(mList.getRefreshableView().getFirstVisiblePosition()+1);
            }
        }
    });

这篇关于如何使列表视图滚动一行在同一时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆