Scrolling 2 fragment (one Fragment and one ListFragment) as one

女生的网名这么多〃 提交于 2019-12-24 10:41:15

问题


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?


回答1:


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

mySecondFragment.getListView().addHeaderView(containerOfFirstFragment).

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.



来源:https://stackoverflow.com/questions/9410747/scrolling-2-fragment-one-fragment-and-one-listfragment-as-one

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!