滚动2片段(一个片段,一个ListFragment)为一体 [英] Scrolling 2 fragment (one Fragment and one ListFragment) as one

查看:199
本文介绍了滚动2片段(一个片段,一个ListFragment)为一体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个复杂的片段(一个片段,并在它下面,有一个 ListFragment )的一项活动,我希望能够滚动整个屏幕,所以我可以看到列表内容的其余部分。我试过把2片段在滚动型,它不会滚动,但名单片段只显示第一行。在那之后,我一直在滚动,但屏幕是空的(没有显示出其他列表行)。

I have 2 complex fragments (one Fragment and, below it, one ListFragment) in an activity and I want to be able to scroll the entire screen so I can see the rest of the list content. I've tried putting the 2 fragments inside a ScrollView and it does scroll but the list fragment only shows the first row. After that, I keep scrolling but the screen is empty (shows no other list rows).

任何人都知道是什么问题,和/或如何解决呢?

Anyone know what the problem is and/or how to solve it?

推荐答案

设置第一个片段作为ListView控件中的第二个片段标题。

Set first Fragment as a header of ListView in the second Fragment.

mySecondFragment.getListView().addHeaderView(containerOfFirstFragment).

在哪里containerOfFirstFragment是containg 1片段的视图(布局)。

Where containerOfFirstFragment is a View (layout) containg 1st Fragment.

也许有可能增加头查看其他方式,但我不求它。

Maybe there is a possibility to add header view another way, but I don't seek it.

这篇关于滚动2片段(一个片段,一个ListFragment)为一体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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