title: Android ListFragment with custom CursorAdapter not showing data
body: <p>So basically I have a ListFragment setup like this</p>
  
  <pre><code>public class ObavijestiFragment extends ListFragment implements LoaderManager.LoaderCallbacks&lt;Cursor&gt; {
  private View mApiError;
  private ObavijestiAdapter mAdapter;
  private static String TAG="ObavijestiFragment";
  
  public static ObavijestiFragment newInstance() {
      return new ObavijestiFragment();
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View v = inflater.inflate(R.layout.fragment_obavijesti, container, false);
      return v;
  }
  
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
      mApiError = view.findViewById(R.id.api_error);
  }
  </code></pre>
  
  <p>Also, I implemented <code>onActivityCreated</code> and <code>onLoadFinished</code> like this</p>
  
  <pre><code>public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      Activity activity = getActivity();
  
      if (!activity.isFinishing()) {
          Loader loader = getActivity().getSupportLoaderManager().getLoader(Config.OBAVIJESTI_CURSOR_ID);
  
          mAdapter = new ObavijestiAdapter(activity, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
  
          setListAdapter(mAdapter);
  
          if (loader != null &amp;&amp; !loader.isReset()) {
              getActivity().getSupportLoaderManager().restartLoader(Config.OBAVIJESTI_CURSOR_ID, null, this);
          } else {
              getActivity().getSupportLoaderManager().initLoader(Config.OBAVIJESTI_CURSOR_ID, null, this);
          }
      }
  }
  
   public void onLoadFinished(Loader&lt;Cursor&gt; loader,Cursor cursor) {
      if(mAdapter!=null &amp;&amp; cursor!=null)
          mAdapter.swapCursor(cursor);
  }
  </code></pre>
  
  <p>My cursor in onLoadFinished has 4 rows of data but non of this rows are shown in my ListView. Can somebody help me with this?? Also <code>bindView</code> or <code>newView</code> in my custom adapter that extends <code>CursorAdapter</code> are newer reached. Below is this Adapter.</p>
  
  <pre><code>public class ObavijestiAdapter extends CursorAdapter {
  private Cursor mCursor;
  private Context mContext;
  private final LayoutInflater mInflater;
  
  static class ViewHolder {
      public TextView hTextNaslov;
      public TextView hTextOpis;
      public ImageView hImage;
  }
  public ObavijestiAdapter(Context context, Cursor c, int flags) {
      super(context, c, flags);
      mInflater = LayoutInflater.from(context);
      mContext = context;
  }
  
  @Override
  public void bindView(View view, Context context, Cursor cursor) {
      final ViewHolder holder = (ViewHolder)view.getTag();
  
      //TODO: REMOVE AFTER IMPLEMENTING REAL IMAGE
      int w = 24, h = 24;
      Bitmap.Config conf = Bitmap.Config.ARGB_8888; // see other conf types
      Bitmap bmp = Bitmap.createBitmap(w, h, conf); // this creates a MUTABLE bitmap
      //END REMOVE
  
      holder.hImage.setImageBitmap(bmp);
      holder.hTextNaslov.setText(cursor.getString(cursor.getColumnIndex(DataContract.Obavijesti.OBAVIJESTI_NASLOV)));
      holder.hTextOpis.setText(cursor.getString(cursor.getColumnIndex(DataContract.Obavijesti.OBAVIJESTI_OPIS)));
  }
  
  
  @Override
  public View newView(Context context, Cursor cursor, ViewGroup parent) {
      View view=mInflater.inflate(R.layout.fragment_obavijesti_row,parent,false);
  
      final ViewHolder holder = new ViewHolder();
      holder.hTextOpis = (TextView) view.findViewById(R.id.obOpis);
      holder.hTextNaslov = (TextView) view.findViewById(R.id.obNaslov);
      holder.hImage = (ImageView) view.findViewById(R.id.oblist_image);
      view.setTag(holder);
      return view;
  }
  </code></pre>
  
  <p><strong>UPDATE:</strong>
  I tryed with SimpleCursorAdapter and just one TextView like this:</p>
  
  <pre><code>String[] from = new String[] {DataContract.Obavijesti.OBAVIJESTI_NASLOV};
      int[]  to = new int[] { R.id.obNaslov };
  
      sAdapter = new SimpleCursorAdapter(getActivity(),
              R.layout.fragment_obavijesti_row, null, from,to , 0);
      setListAdapter(sAdapter);
  
      getActivity().getSupportLoaderManager().initLoader(0, null, this);
  </code></pre>
  
  <p>but no luck. Again in, <code>onLoadFinished</code> the cursor.getCount()=4 and this is the right number</p>
  
  <p><strong>UPDATE 2:</strong>
  So, after putting  <code>ListView lv = (ListView) getActivity().findViewById(R.id.obList);</code> and <code>lv.setAdapter(mAdapter);</code> instead of <code>setListAdapter</code> everything is ok... But now I have another problem. I am expecting main activity (that includes support ActionBar) to load first and after that a progress bar to show when data in the ListView is loading. This is why I implemented CursorLoader in the first place. I tried to put <code>Thread.sleep(9000);</code> in <code>onCreateLoader</code> for testing, but whole activity screen loades at the same time, so the whole UI is stopped for 9 seconds. What am I doing wrong??</p>