0

I want to create a layout composed of :

  • textview, as a title
  • listview

and all when the user scrolls down/up all the content scrolls together (not only inside the listview) Any ideas?

just_user
  • 11,769
  • 19
  • 90
  • 135

2 Answers2

2

Why don't you load the title into the listview, as the top item, and make your activity extend ListActivity?

If you want the title to be formatted differently, you can specify this on the getView() method --

if (position == 0) {
   //format title item }
else {
   //format other items 
drew moore
  • 31,565
  • 17
  • 75
  • 112
2

You can define your textview like this:

View textView = ((LayoutInflater)Activity.this.getSystemService(Activity.this.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.textview_title, null, false);

and then add it as a listview header

myListView.addHeaderView(textView);

If you want to set the selection to be the first list item after the header view you can use

myListView.setSelectionAfterHeaderView();
mirenibg
  • 96
  • 1
  • 2