问题
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