0

I am not sure how to go about doing this. This is my requirements for an Activity:

  1. Header
  2. ListView of 10 items
  3. Header
  4. ListsView of 10 items

The ListViewsare coming from two different data sources and may have two different row layouts. So I am thinking I need to make two Custom adapter classes (two getView()'s, etc).

Here's the kicker, I want to be able to pull-to-refresh the whole list and update both ListViews. If that is too much, I'll settle with a refresh button (that Google seems to prefer anyway); currently I use com.handmark.pulltorefresh.library.PullToRefreshListView

Is this possible? If so, what is best steps to make this work?

TheLettuceMaster
  • 15,594
  • 48
  • 153
  • 259

2 Answers2

1

MergeAdapter will help you to merge any number of headers and adapters into a single one. So basically in your activity only one ListView is needed and this ListView should be use a merge adapter with two headers and two custom adapters.

Merge Adapter

JogahCR
  • 134
  • 4
1

Very much possible. Approach can be one ScrollView with one LinearLayout child(vertical orientation). Now two ListView as child views for linearlayout. As you said already,you will need two adaptors(with different row layout). Each list can have its own Header View.

For PulltoRefresh functionality, you can have a look at pulltorefresh library This allows you to make any View as pull to refresh. As i explained above you need ScrollView as root view, So you need to use PullToRefreshScrollView from above library.

Akhil
  • 6,667
  • 4
  • 31
  • 61
  • Good idea on pull-to-refresh on non-ListView items. The one I am using does that as well. Thank you very much, you gave me some ideas! Last question: in the activity, I can't really do `getListView()` -- how do I differentiate them since I need to set two different `adapters`? – TheLettuceMaster Apr 24 '13 at 19:21
  • 1
    you need to give different ids to each ListView in your layout xml say "android:id="@+id/listView_1" & "android:id="@+id/listView_2" and use ListView l1 = (ListView) findViewById(R.id.listView_1) for finding it your activity. – Akhil Apr 24 '13 at 19:24