I'm aware of the setListShown(false) and setListShown(true) issue when using the Compatibility Library with ListFragments, but how do I display a ListFragment regardless of this bug? My ArrayAdapter getView() method never fires for some reason...
Bug: http://code.google.com/p/android/issues/detail?id=17096
DateAdapter.java
class DateAdapter extends ArrayAdapter<DateVO> {
//constructor
public DateAdapter(Context context) {
super(context, android.R.layout.simple_list_item_2);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Log.i("tag", "getView"); //never called
...
MyFragment.as
public class MyFragment extends ListFragment implements LoaderCallbacks<ArrayList<DateVO>> {
...
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
m_adapter = new DateAdapter(context);
setListAdapter(m_adapter);
开发者_如何学运维 //setListShown(false);
//initialize the loader
getLoaderManager().initLoader(0, null, this);
}
...
It looks like you have found a way around this. For the future, if you are using the support compatibility library, you might want to try getSupportLoaderManager().
Ok, got this to load content from my custom loader... finally! And since setListShown(true|false) doesn't work properly with the compatibility lib, I simply created a custom ProgressDialog added via a DialogFragment. If you wish to see code just respond and I'll post.
精彩评论