title: Android: Custom ArrayAdapter not working, getView() not getting called
body: <p>I am using <code>CustomArrayAdapter</code> with <code>ListView</code>. But, even after setting  <code>setAdapter</code> it is not working. Following are my code snippets:</p>
  
  <p><strong>PastOrders.java</strong>   Fragment displaying listView</p>
  
  <pre><code>public class PastOrders extends Fragment {
  private View view;
  private ListView pastOrdersList;
  private Context context;
  private ArrayList&lt;Order&gt; orders;
  public PastOrders() {
  
  }
  
  @Override
  public View onCreateView(final LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      super.onCreateView(inflater, container, savedInstanceState);
      view = inflater.inflate(R.layout.fragment_pastorders, container, false);
      context = getActivity();
      pastOrdersList = (ListView) view.findViewById(R.id.pastOrdersList);
  
      ParseQuery&lt;ParseObject&gt; query  = ParseQuery.getQuery("Order");
      query.whereEqualTo("user_id", Vars.currentUser);
  
      query.findInBackground(new FindCallback&lt;ParseObject&gt;() {
          @Override
          public void done(List&lt;ParseObject&gt; objects, ParseException e) {
              if(e != null) {
                  Log.e("TAG", e.getLocalizedMessage());
              } else {
  
                  ArrayList&lt;Order&gt; orders = new ArrayList&lt;Order&gt;();
  
                  Log.i("TAG", objects.toString());
  
                  for (ParseObject object: objects) {
                      Order temp = new Order();
                      temp.orderId = object.getObjectId();
                      temp.date = object.getCreatedAt();
                      temp.status = object.getString("status");
                      Log.i("TAG", "orderID: "+ object.getObjectId() + " temp orderID"+ temp.orderId);
                      orders.add(temp);
                      Vars.pastOrders.add(object);
                  }
  
                  Log.i("TAG", "after for loop past orders: "+ orders.toString());
                  PastOrdersAdapter pastOrdersAdapter = new PastOrdersAdapter(getActivity(), R.layout.past_orders_row, orders);
                  pastOrdersList.setAdapter(pastOrdersAdapter);
  
              }
          }
      });
  
      return view;
  }
  
  @Override
  public void onResume() {
      super.onResume();
  }
    }
  </code></pre>
  
  <p><strong>PastOrdersAdapter.java</strong> Custom Adapter</p>
  
  <pre><code>public class PastOrdersAdapter extends ArrayAdapter&lt;Order&gt; {
  
  private Context context;
  private ViewHolder holder;
  //private ArrayList&lt;Order&gt; orders;
  
  public PastOrdersAdapter(Context context, int resource, List&lt;Order&gt; orders) {
      super(context, resource);
     // this.orders = orders;
      Log.i("TAG", "POA adapter called");
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      Log.i("TAG", "getView from POA");
      LayoutInflater inflater = ((Activity) context).getLayoutInflater();
      if (convertView == null) {
          convertView = inflater
                  .inflate(R.layout.past_orders_row, parent, false);
          holder = new ViewHolder();
          holder.orderId = (TextView) convertView.findViewById(R.id.orderId);
          holder.date = (TextView) convertView.findViewById(R.id.date);
          holder.status = (TextView) convertView.findViewById(R.id.status);
  
          holder.details = (ImageView) convertView.findViewById(R.id.details);
  
  
          convertView.setTag(holder);
      } else {
          holder = (ViewHolder) convertView.getTag();
      }
  
      ParseObject order = Vars.pastOrders.get(position);
  
      Log.i("TAG", "order id in adapter: "+ order.getObjectId());
  
      if(order != null) {
          holder.orderId.setText(order.getObjectId());
          holder.date.setText(getFormattedDate(order.getCreatedAt()));
          holder.status.setText(order.getString("status"));
  
          if(order.getString("status").equals("Delivered")) {
              holder.status.setTextColor(Color.GREEN);
          } else if(order.getString("status").equals("Cancelled")) {
              holder.status.setTextColor(Color.RED);
          } else {
              holder.status.setTextColor(Color.YELLOW);
          }
      }
  
  
      return convertView;
  }
  
  static class ViewHolder {
  
      TextView orderId;
      TextView date;
      TextView status;
  
      ImageView details;
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Order.java</strong></p>
  
  <pre><code>public class Order {
  
  public String orderId;
  public Date date;
  public String status;
  }
  </code></pre>
  
  <p><strong>fragment_pastorders.xml</strong> Layout File for Fragment showing ListView</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" &gt;
  
  &lt;ListView
      android:id="@+id/pastOrdersList"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  &lt;/ListView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>past_orders_row.xml</strong> Layout file for each row of listview</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="150dp"&gt;
  
  &lt;LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="150dp"
      android:orientation="vertical"
      android:id="@+id/LinearLayout01"&gt;
  
      &lt;TextView
          android:id="@+id/orderId"
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"
          android:textStyle="bold" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/date"
          android:textStyle="italic"/&gt;
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/status"/&gt;
  &lt;/LinearLayout&gt;
  
  &lt;ImageView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/ic_action_next_item"
      android:layout_toRightOf="@id/LinearLayout01"
      android:layout_centerVertical="true"
       android:id="@+id/details"/&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I have tried printing getCount() as well and it is non-zero. I have tried everything. Kindly help</p>
  
  <p>Thanks,</p>
  
  <p>Arpit</p>