Question

I want to create the following layout:

  1. Section '1' is a LinearLayout which contains an ImageView and a TextView
  2. Section '2' is a ListView with customized row layouts.

I want to place both components under a single vertical ScrollBar, meaning I don't want the ScrollBar only for the ListView. Currently I'm achieving the following layout through placing things in a TableView but I want functionality like ListView items.

alt text http://img8.imageshack.us/img8/5386/detaili.jpg

Was it helpful?

Solution

You can programmatically add 'Section 1' as a header view to the ListView using ListView.addHeaderView(View v). See docs here.

Example code here:

View headerView = getLayoutInflater().inflate(
        R.layout.foo_list_header, null);

mListView = (ListView) findViewById(...);
mListView.addHeaderView(headerView);

setListAdapter(...);

OTHER TIPS

You could make a "Section 1" to be a part of your list. Just add another type for your customized items list, add "section 1" as first element of your list , and your scrollbar will work as you desired.
I think that is the most convenient approach.
Regards!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top