I'm trying to add a ListFragment to an Activity in Gingerbread, but Android crashes when the Activity is created and there is no stack trace. I have verified that I'm using the compatibility library imports. Here is my code for the ListFragment:
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
public class ListViewFragment extends ListFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
List listData = getListData().
setListAdapter(new ListViewAdapter(getActivity(), listData));
}
class ListViewAdapter extends BaseAdapter implements ListAdapter {
.
.
.
}
}
I also tried:
ListView listView = getListView();
listView.setAdapter(new ListViewAdapter(getActivity(), listData);
in place of the setListAdapter() call with the same results.
When I extend from just a Fragment and inflate a layout file with a ListView, it works fine. There seems to be something different when I try to use the inherent ListView in the ListFragment.
Any insight would be much appreciated.