开发者

ListView and LineraLayout under one ScrollBar

开发者 https://www.devze.com 2022-12-15 01:39 出处:网络
I want to create the following layout: Section \'1\' is a LinearLayout which contains an ImageView and a TextView

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 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!

0

精彩评论

暂无评论...
验证码 换一张
取 消