Reputation: 1879
Is it possible to have a ListView
that draws from multiple sources? I want to have some hard-coded items and items from a ContentProvider
in the same list, and I just want to know if that's possible.
Upvotes: 0
Views: 36
Reputation: 1879
So, I realized that
ContentProvider
data is updated after the fragment loads andContentProvider
. So I'm going to dump my cursor results into an ArrayList
along with my hardcoded items, and I think that should work fine.
Upvotes: 0
Reputation: 9274
You could have both types of items implement an interface such as
public interface Item {
int TYPE_1 = 1;
int TYPE_2 = 2;
int getViewType();
View getView(LayoutInflater inflater, View convertView, ViewGroup parent);
}
Then your Adapter
can be for a list of Item
s. Also, if you're unfamiliar with the View Holder pattern I'd recommend looking it up. A quick search revealed a pretty good looking example here
Upvotes: 1
Reputation: 311
You can let them extends a common parent class, and then use it to construct the adapter. I have done this before, I hope to help you.
Upvotes: 0