1

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.

Chris
  • 125
  • 1
  • 3
  • 12
  • There are lot's of tutorials on web. Try searching for those. One of them is here: http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html – Kumar Bibek Apr 02 '13 at 06:42
  • can you give me some parameters to search for because "listfragment tutorial" is what's been giving me the aforementioned static data tutorials – Chris Apr 02 '13 at 17:21
  • Search "Custom List View" Implementing it in a fragment is no different than that in an activity. – Kumar Bibek Apr 02 '13 at 17:46
  • ok will do.. I think I just don't know enough to know what I should be searching for. its called a listfragment in the tutorial I followed so I've just been looking for that. – Chris Apr 02 '13 at 19:06

0 Answers0