ListView控件里的GridView不滚动? [英] ListView inside GridView not Scrolling?

查看:106
本文介绍了ListView控件里的GridView不滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示项的GridView控件,每一项都是一个ListView。

问题是,我不能滚动ListView的项目,似乎是在GridView是获得焦点或$ P $从列表视图

pventing它

有没有解决办法呢?

感谢

**

  

编辑:

** 这里是我的活动布局

 < GridView控件
        机器人:ID =@ + ID /格
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:verticalSpacing =35dp
        机器人:horizo​​ntalSpacing =10dp
        机器人:为numColumns =auto_fit
        机器人:columnWidth中=300dp
        机器人:stretchMode =columnWidth中

        />
< / LinearLayout中>
 

每个GridView的项目具有以下布局:

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:方向=垂直
     >

    <的ListView
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:ID =@ + ID /列表
         />

< / LinearLayout中>
 

解决方案

您不能有一个父视图是滚动中的滚动子视图。谷歌不推荐它,而且它是非常的混乱。 阅读本

曾有人谁一直在试图做一个解决方法(这看起来并不pretty的),但我怀疑它会为你工作。但是你可以反正读它,看看您是否可以让他为你工作。 <一href="http://stackoverflow.com/questions/4097385/listview-in-scrollview-potential-workaround">Enjoy.

其中一个主要的原因,它不会工作是因为这样可滚动的意见处理触摸。有一个方法称为 dispatchTouchEvent() onInterceptTouchEvent()的决定是否拦截触摸事件,或把它传递给它的儿童。对于可滚动的看法,他们总是拦截刷卡运动。因此,它永远不会给你的孩子。

您可以尝试修改它,但如果你仔细想想,你怎么会知道,如果你想滚动父母或如果你想滚动的孩子?试想一下,如果你的滚动的孩子中的一个最终把你的屏幕的宽度,但你要滚动你的父母,你将如何处理呢?

摘要: 我们不推荐....如果你真的坚持......然后继续写自己的自定义视图来处理逻辑。但我向你保证它不会是pretty的,并且几乎从来没有适​​用于所有用例。

I have a GridView that displays items, each item is a ListView.

the problem is that I can't scroll the ListView items, seems like the GridView is obtaining the focus or preventing it from the ListViews

is there a workaround for this ?

thanks

**

EDIT:

** here's my activity layout

<GridView
        android:id="@+id/grid"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:verticalSpacing="35dp"
        android:horizontalSpacing="10dp"
        android:numColumns="auto_fit"
        android:columnWidth="300dp"
        android:stretchMode="columnWidth"

        />
</LinearLayout>

each gridview item has the following layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
     >

    <ListView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/list"
         />

</LinearLayout>

解决方案

You cannot have a scrollable child view within a parent view that is scrollable. Google does not recommend it... and it's really messy. Read this

There have been people who've been trying to do a workaround (which doesn't look pretty), but I doubt it will work for you. But you can read it anyways and see if you can make it work for you. Enjoy.

One of the main reasons why it wont work is because of the way scrollable views handle touch. There's a method called dispatchTouchEvent() and onInterceptTouchEvent() that decides whether to intercept the touch event or pass it to it's children. For scrollable views, they will always intercept "swipe" movements. So it will never go to your children.

You can try to modify it, but if you think about it, how will you know if you're trying to scroll the parent or if you're trying to scroll the child? Imagine if the one of your scrollable children ends up taking the width of your screen, but then you want to scroll your parent, how will you manage that?

Summary: it's not recommended .... if you really insist... then go ahead and write your own custom view to handle the logic. But i guarantee you it wont be pretty and will almost never work for all use cases.

这篇关于ListView控件里的GridView不滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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