ListView and LineraLayout under one ScrollBar
I want to create the following layout:
- Section '1' is a
LinearLayout
which contains anImageView
and aTextView
- 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 function开发者_StackOverflow中文版ality like ListView
items.
alt text http://img8.imageshack.us/img8/5386/detaili.jpg
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(...);
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!
精彩评论