我怎样才能让我的ListView滚动? [英] How can I get my ListView to scroll?

查看:129
本文介绍了我怎样才能让我的ListView滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当复杂的视图集结,并作为其中的一部分,我有一个滚动型中的ListView中的LinearLayout内(和相当多的更多的组件,但他们没有在这个问题上关系)。

现在整个活动很好地滚动,因为它应该,但在ListView具有高度有限,而当它里面的项目超越的高度,在我的屏幕消失。我试图把里面的自己的滚动型ListView控件,但这不起作用。当我尝试滚动ListView中,主要的滚动型选择和我的屏幕滚动,而不是在ListView。

我的问题可能听起来容易,但我一直没能解决这个问题?是否有可能使ListView的滚动藏汉?

相关的XML:

 <滚动型的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
            机器人:layout_width =match_parent
            机器人:layout_height =match_parent>

    <的LinearLayout机器人:ID =@ + ID / GlobalLayout
                  机器人:layout_width =FILL_PARENT
                  机器人:layout_height =FILL_PARENT
                  机器人:方向=垂直>

        < ListView的机器人:ID =@ + ID / EndpointList
                  机器人:choiceMode =multipleChoice
                  机器人:layout_height =175dip
                  机器人:layout_width =FILL_PARENT/>

    < / LinearLayout中>

< /滚动型>
 

解决方案

其实,我有它设置为真正的工作......在滚动型中的LinearLayout中放置一个ListView的方式。只要避免该ListView的是滚动型的直子,它会制定得很好......

要知道,如果没有足够的项目在ListView来填补它,所以它变为关闭屏幕,它不会滚动(一种逻辑上虽然)。还要注意的是,当你有足够的项目滚动,你需要保持pressing上的项目在ListView使其滚动,有一半的时间,重点是考虑到全球的滚动视图中的ListView代替。 。要避免这种情况(大部分时间),保持pressing在最顶部或最下的项目,这取决于你想scroll.This哪种方式将优化你的机会获得专注于你的ListView。

我做了一个视频,这是可能的,我现在上传到YouTube ...

视频 http://www.youtube.com/watch?v=c53oIg_3lKY。质量是有点坏,但它证明了我的观点。

只是一个全球概览,我用了滚动型是能够滚动我的整个活动中,为的LinearLayout活动的布局,并在ListView,好了,做出的排行榜...

I have a quite complex View build-up, and as a part of that, I have a ListView inside a LinearLayout within a ScrollView (and quite a lot more components, but they do not matter in this issue).

Now the whole activity scrolls nicely as it should, but the ListView has a limited height, and when the Items inside it surpass the height, the disappear of my screen. I've tried to place the ListView inside it's own ScrollView, but this doesn't work. When I try to scroll on the ListView, the main ScrollView is selected and my screen scrolls instead of the ListView.

My question may sound easy, but I haven't been able to fix this... Is it possible to make the ListView scrollable aswell?

The relevant XML:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

    <LinearLayout android:id="@+id/GlobalLayout" 
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:orientation="vertical" >

        <ListView android:id="@+id/EndpointList"
                  android:choiceMode="multipleChoice"
                  android:layout_height="175dip"
                  android:layout_width="fill_parent" />

    </LinearLayout>

</ScrollView>

解决方案

Actually, the way that I have it set up is really working... Placing a ListView in a LinearLayout within a ScrollView. Just avoid that the ListView is the direct child of the ScrollView, and it will work out just fine...

Just be aware that if there aren't enough items in the ListView to fill it so it goes 'off screen', that it won't scroll (kind of logically though). Also note that when you have enough items to scroll through, you need to keep pressing on an item in the ListView to make it scroll, and half of the time, focus is given to the global scrollview in stead of the ListView... To avoid this (most of the time), keep pressing on the most top or most down item, depending on which way you want to scroll.This will optimize your chance to get focus on your ListView.

I've made a video that it is possible, am uploading it now to YouTube...

Video is http://www.youtube.com/watch?v=c53oIg_3lKY. The quality is kinda bad, but it proves my point.

Just for a global overview, I used the ScrollView to be able to scroll my entire activity, the LinearLayout for the Activity's layout, and the ListView to, well, make the list...

这篇关于我怎样才能让我的ListView滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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