如何与另一个滚动视图滚动的ListView [英] How to scroll ListView with in another scroll view

查看:120
本文介绍了如何与另一个滚动视图滚动的ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应对所有,
         我有个问题;
         我已经在三个列表视图中A,B,C与滚动视图的布局。
         我想滚动孔布局,以及滚动每个列表视图。

Deal All, I have a problem; I have a layout with scroll view over three list view A,B,C. I want scroll hole layout as well as scroll each list view.

问题:
       当如果我删除滚动布局布局滚动列表视图不会再滚动列表滚动,但布局不滚动。

problem: List view are not scroll when layout is scroll if I remove scroll layout then list is scroll but layout is not scroll.

请给我任何可能的解决方案的在此先感谢。

Please give me a any possible solution Thanks in advance.

推荐答案

使用下面的方法,并享受!

Use the following method and enjoy!

    private void setListViewScrollable(final ListView list) {
    list.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            listViewTouchAction = event.getAction();
            if (listViewTouchAction == MotionEvent.ACTION_MOVE)
            {
                list.scrollBy(0, 1);
            }
            return false;
        }
    });
    list.setOnScrollListener(new OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view,
                int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem,
                int visibleItemCount, int totalItemCount) {
            if (listViewTouchAction == MotionEvent.ACTION_MOVE)
            {
                list.scrollBy(0, -1);
            }
        }
    });
}

listViewTouchAction是一个全球性的整数值。
如果你可以替换该行

listViewTouchAction is a global integer value. If you can replace the line

list.scrollBy(0, 1);

用别的东西,请与我们分享。

with something else please share it with us.

这篇关于如何与另一个滚动视图滚动的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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