Android的垂直滚动用于滚动视图水平的ListView里面 [英] Android Vertical scrolling for ListView inside Horizontal scrollView

查看:173
本文介绍了Android的垂直滚动用于滚动视图水平的ListView里面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ListView这是一个水平scrollView.The水平滚动内自定义ArrayAdapter工作正常,但垂直滚动我不得不做一些黑客。
我只是想知道,如果它是一个好主意,因为ListView控件用于垂直滚动已经过优化。?
有什么办法没有这个黑客滚动?

I have a custom ArrayAdapter for a listView which is inside a horizontal scrollView.The horizontal scrolling works fine but for vertical scrolling I had to do some hacks. I just want to know if its a good idea since listView is already optimized for vertical scrolling.? Is there a way to scroll without this hack ?

该黑客主要是捕捉到的TouchEvent了滚动(父类),并使用TouchEvent传播到ListView控件。

The hack basically is to capture touchEvent for scrollView(parent class) and propagate the touchEvent to ListView.

scrolLView.setOnTouchListener(new OnTouchListener(){

        @Override
    public boolean onTouch(View arg0, MotionEvent arg1) {
            lv.setSmoothScrollbarEnabled(true);
            lv.dispatchTouchEvent(arg1);
        }
});

这会导致滚动发生,工作的事情。
我只是想知道是否有一定的更多的东西,我需要采取的责任。

This causes scrolling to happen and things work. I just want to know if there are certain more things i need to take in to account.

感谢

推荐答案

您水平滚动视图是父类,所以只能滚动视图,而不是列表视图触摸事件将被识别。所以如果你想列表视图中滚动,你做的方式是正确的。

Your horizontal scroll view is in parent class, so the touch event will be recognized only for the scroll view and not for the list view. So if you want the list view to scroll, the way you did is correct.

这篇关于Android的垂直滚动用于滚动视图水平的ListView里面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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