Ok, so I started with the android template that uses "dummycontent" to populate the list fragment.
Now I have real data (in an sqldatabase) that I need to use, but I cant figure out how to replace dummy content.
the oncreate of the fragment looks like this:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: replace with a real list adapter.
setListAdapter(
new ArrayAdapter<JobData.JobItem>
(
getActivity(),
android.R.layout.simple_list_item_activated_1,
android.R.id.text1,
JobData.ITEMS
)
);
}
I have it structured like that to help me understand what's happening.
From what I can understand, we are setting the list adapter to a list of JobData.JobItem items, right? I understand that far. my problem is, all the examples I can find implement the data class with static content. using something like this:
static {
// Add 3 sample items.
addItem(new DummyItem("1", "Item 1"));
addItem(new DummyItem("2", "Item 2"));
addItem(new DummyItem("3", "Item 3"));
}
But, that doesn't work if my information isn't static... so here are my questions:
1) How do I update the information in the data class (jobdata/dummyitems)?
2) does the list fragment contain an instance of the data class, or is the data class one entity, such that if I modify it from a separate process the listfragment will update?
3) How do I initialize data in the data class, if it never actually seems to get called (set to a variable) anywhere? It looks like static{} runs automatically at some point, but i don't know where.
I may be missing something simple, but I've been stuck on this for a couple of days. I tried going through some "simple" listfragment tutorials, but they all seem to use static data.
I can get the data from my db and into a list for processing just fine. but I don't know how to get that list into the listfragment.