当列表视图在滚动视图中时如何工作? [英] How to work, when listview inside the scrollview?

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

问题描述

我在 Android 1.6 和 2.2 中这样做...

I doing this In Android 1.6 and 2.2 ...

我在活动中有一个 ScrollView(滚动视图中的所有内容)...

I have One ScrollView in the Activity (All the content in the ScrollView) ...

第二个是,Activity 中的一个 ListView ....

And Second is, One ListView in the Activity ....

当我滚动 ListView 时,当时 ScrollView 正在滚动但 ListView 的 Scroll 不起作用 ...

When I Scroll ListView, at that time ScrollView is scrolling but ListView's Scroll is not working ...

我提供了我遇到的问题scatch ...

I provide the scatch of the problem which I have ...

如果有人解决了这个问题,请分享......

If anyone have solution of this, then please share ...

推荐答案

here parentScroll = your main scrollview和 childScroll = 你的列表视图

here parentScroll = your main scrollview and childScroll = your listview

parentScroll.setOnTouchListener(new View.OnTouchListener() {

                public boolean onTouch(View v, MotionEvent event) {
                    Log.v("PARENT", "PARENT TOUCH");
                    findViewById(R.id.child_scroll).getParent()
                            .requestDisallowInterceptTouchEvent(false);
                    return false;
                }
            });

  childScroll.setOnTouchListener(new View.OnTouchListener() {

                public boolean onTouch(View v, MotionEvent event) {
                    Log.v("CHILD", "CHILD TOUCH");
                    // Disallow the touch request for parent scroll on touch of
                    // child view
                    v.getParent().requestDisallowInterceptTouchEvent(true);
                    return false;
                }
            });

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

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