views:

272

answers:

1

I know it's considered taboo to place a ListView inside a scrolling container, so is there any "proper" way to accomplish scrolling of a container that has a ListView child in it? An example layout would look something like:

Header
---
"Sub" header
---
ListView with list items
---
Footer

Header and Footer need to remain static on the screen, and the middle content (Subheader and ListView) should scroll between them. I can't have just the ListView scrollable, because the subheader takes up too much space. As it is currently, the Header comes from an <include />, the Subheader contains several views including an Image and some text, and the ListView (actually part of a ViewFlipper) would contain an indeterminate number of items. The Footer has a couple buttons/tabs that are used to control the ViewFlipper (only one of the views in the flipper is a ListView).

The only way I can think of to accomplish this efficiently would be to place the Subheader inside the ListView as the first item -- is there any better way?

+1  A: 

I know it's considered taboo to place a ListView inside a scrolling container

It's not "taboo", it just will never work.

The only way I can think of to accomplish this efficiently would be to place the Subheader inside the ListView as the first item -- is there any better way?

You could use addHeader() on ListView to set up your "Subheader" as a ListView header.

CommonsWare
Sounds like that's the nudge I needed! [note: it's addHeaderView(View)] I usually read the reference docs, I don't know why I didn't notice you could have a header :( I'll give that a shot and post back. Thanks.Though one minor issue I can probably work around: The "ListView" section is part of a ViewFlipper, and the other views in the flipper are not ListViews. Does this mean I'd need to basically move the subheader into the ListView programmatically when it's flipped to, and then move it back outside the ListView (and outside the Flipper) when flipping to a different view?
Joe