It seems to me that you need a combination of the "static text" approach with the "section headings" in ScrollView: the list should contain elements with disabled / inaccurate code with the letters "A", "B", etc. When the section title scrolls over the top of the view, change the contents of the static TextView above ScrollView to the contents of the title. Ie, when the title element βBβ scrolls out of view, the TextView now contains βBβ.
Of course, the hard part will determine when the "section header" scrolls from the top or appears when scrolling in the opposite direction.
For bonus points, use the "push up" animation in the TextView when changing content so that it looks like a list item rolls in the TextView. (An example of this animation in the Demos API application in the SDK is shown in "... \ view \ Animation2.java").
UPDATE: after further consideration ... here are some classes, etc. related to doing this work (it was a fun exercise for me!):
android.widget.AbsListView.OnScrollListener to learn how to define scroll events. You will need to follow the previous βtopβ position to determine which direction you are scrolling (to select a slide animation or down).
The animation above is not really what you want - it's better to look at the android.widget.TextSwitcher class and push*.xml in the SDK / android-X / data / res / anim directory.
You will definitely need your own adapter subclass to insert sections into the list: getView(...) can distinguish between the properties of the string type (bkgnd, text style, etc.) otherwise if the string is the section title or not. Reuse this code in the TextSwitcher factory view to populate the static TextView / Switcher above the list.
Good luck ...!
source share