title: Blank ListView with no errors in Logcat - Android & custom adapter
body: <p>I've been trying to create a listView that display event items, only it isn't showing anything. I've pretty much just followed <a href="http://www.javacodegeeks.com/2012/10/android-listview-example-with-image-and.html" rel="nofollow">this</a> example. My dq.getAllEventsCategory() method returns an Arraylist of Event Items.</p>
  
  <p>Here's my Activity:</p>
  
  <pre><code>public class CategoryActivity extends ActionBarActivity {
  DatabaseQueries dq = new DatabaseQueries(this);
  private ArrayList&lt;Event&gt; eventDetails;
  public String typeSearchTerm;
  
  
  
  
  @Override
  public void onCreate(Bundle savedInstanceState)  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_category);
  
  
      Intent i = getIntent();
     typeSearchTerm = i.getStringExtra(String.valueOf(R.string.event_type_extra));
  
  
  
      //TRY TO FILL THE ARRAYLIST WITH ALL EVENTS
      DatabaseQueries dq = new DatabaseQueries(this);
      try {
          //eventDetails = dq.getAllEventsCategory(typeSearchTerm);
          eventDetails = dq.getAllEvents();
          Log.d("ARRAY SIZE", eventDetails.size() + "");
          Date d = new Date();
         // Event e = new Event("BBQ", "bottle cap",d, "This is an event", "www.google.com", d, d );
         // eventDetails.add(e);
         // Log.d("Array Size after", eventDetails.size() + "");
      } catch (ParseException e) {
          e.printStackTrace();
      }
  
  
      final ListView lv1 = (ListView)findViewById(R.id.categoryListView);
  
      lv1.setAdapter(new eventItemAdapter(this, eventDetails));
  
      lv1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; a, View v, int position, long id) {
              Object o = lv1.getItemAtPosition(position);
              Event objEvent = (Event)o;
              Toast.makeText(CategoryActivity.this, "You have chosen : " + " " + objEvent.getEventName(), Toast.LENGTH_SHORT).show();
          }
      });
  
  
  }}
  </code></pre>
  
  <p>My Adapter:</p>
  
  <pre><code>public class eventItemAdapter extends BaseAdapter{
      private static ArrayList&lt;Event&gt; eventDetails;
      private LayoutInflater mInflater;
      private static final SimpleDateFormat parser = new SimpleDateFormat("dd/MM/yyyy"); //dd-MM-yyyy
      private static final SimpleDateFormat parseTime = new SimpleDateFormat("hh:mm a");//hh:mm a
  
      public eventItemAdapter(Context context, ArrayList&lt;Event&gt; results) {
          eventDetails = results;
          mInflater = LayoutInflater.from(context);
  
      }
  
      @Override
      public int getCount() {
          return eventDetails.size();
      }
  
      @Override
      public Object getItem(int i) {
          return eventDetails.get(i);
      }
  
      @Override
      public long getItemId(int i) {
          return i;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          ViewHolder holder;
          if(convertView == null){
              convertView =  mInflater.inflate(R.layout.listview_row, null);
              holder = new ViewHolder();
              holder.eventDetailName = (TextView)convertView.findViewById(R.id.eventDetailsName);
              holder.eventDetailLocation = (TextView)convertView.findViewById(R.id.eventDetailsLocation);
              holder.eventDetailDate = (TextView)convertView.findViewById(R.id.eventDetailsDate);
              holder.eventDetailStartTime = (TextView)convertView.findViewById(R.id.eventDetailsStartTime);
  
              convertView.setTag(holder);
          } else{
              holder = (ViewHolder)convertView.getTag();
          }
  
          holder.eventDetailName.setText(eventDetails.get(position).getEventName());
          holder.eventDetailLocation.setText(eventDetails.get(position).getEventLocation());
          Date temp = new Date();
          temp = eventDetails.get(position).getEventDate();
          holder.eventDetailDate.setText(parser.format(temp));
          Date tempTime = new Date();
          tempTime = eventDetails.get(position).getEventStartTime();
          holder.eventDetailStartTime.setText(parseTime.format(tempTime));
  
          //Return the current view
          return convertView;
      }
  
  
      static class ViewHolder{
          TextView eventDetailName;
          TextView eventDetailLocation;
          TextView eventDetailDate;
          TextView eventDetailStartTime;
      } }
  </code></pre>
  
  <p>This is the item View:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="horizontal"
      android:weightSum="1"&gt;
  
      &lt;ImageView
          android:id="@+id/event_photo"
          android:layout_width="100dp"
          android:layout_height="100dp"
          android:layout_marginBottom="5dp"
          android:layout_marginLeft="10dp"
          android:layout_marginRight="10dp"
          android:layout_marginTop="10dp"
          android:src="@drawable/ic_launcher" /&gt;
  
      &lt;LinearLayout android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"&gt;
  
          &lt;TextView
              android:id="@+id/eventDetailsName"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Event Name"
              android:textAppearance="?android:attr/textAppearanceMedium"
              android:textColor="#33CC33"
              android:layout_marginTop="25dp"
              android:layout_marginBottom="6dp" /&gt;
  
          &lt;TableLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
  
              &lt;TableRow
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"&gt;
  
                  &lt;TextView
                      android:id="@+id/time"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Time: "
                      android:layout_marginRight="5dp" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="New Text"
                      android:id="@+id/eventDetailsStartTime"
                      android:layout_column="3" /&gt;
              &lt;/TableRow&gt;
  
              &lt;TableRow
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"&gt;
  
                  &lt;TextView
                      android:id="@+id/date"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Date: "
                      android:layout_marginRight="5dp" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="New Text"
                      android:id="@+id/eventDetailsDate"
                      android:layout_column="3" /&gt;
              &lt;/TableRow&gt;
  
          &lt;/TableLayout&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;TableRow
          android:layout_width="wrap_content"
          android:layout_height="match_parent"&gt;
  
          &lt;TextView
              android:id="@+id/location"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Location: "
              android:layout_marginRight="5dp" /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="New Text"
              android:id="@+id/eventDetailsLocation"
              android:layout_column="3" /&gt;
      &lt;/TableRow&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceMedium"
          android:text="Medium Text"
          android:id="@+id/textView7" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And the the actual ListView:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"&gt;
  
      &lt;include
          android:id="@+id/app_bar"
          layout="@layout/app_bar" /&gt;
  
      &lt;ListView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/categoryListView"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Code for getAllEventsCategory():</p>
  
  <pre><code>public ArrayList&lt;Event&gt; getAllEventsCategory(String category) throws ParseException {
      SQLiteDatabase dq = this.getReadableDatabase();
      ArrayList&lt;Event&gt; global = new ArrayList&lt;Event&gt;();
  
  
      String query = "SELECT e." + EVENT_ID + ", e." + EVENT_NAME + ", e." + EVENT_SOCIETY_ID + ", e."
              + EVENT_LOCATION + ", e." + EVENT_LINK + ", e." + EVENT_START_TIME + ", e."
              + EVENT_END_TIME + ", et." + EVENT_TYPE + " FROM " + TABLE_EVENT + " e LEFT JOIN "
              + TABLE_HAS_CATEGORY + " h ON e." + EVENT_ID + " = h." + HAS_EVENT_ID
              + " JOIN " + TABLE_EVENT_TYPE + " et ON h." + HAS_EVENT_TYPE_ID + " = et."
              + EVENT_TYPE_ID + " where et." + EVENT_TYPE + " = \"" + category + "\";";
  
      Log.d("QUERY ", "" + query);
  
      Cursor cursor = dq.rawQuery(query, null);
      int numRows = cursor.getCount();
  
      //for loop to add each event to the arraylist
      for (int i = 0; i &lt; numRows; i++) {
          Event e = new Event();
  
          e.setEventID(Integer.parseInt(cursor.getString(0)));
          e.setEventName(cursor.getString(1));
          e.setSocietyID(Integer.parseInt(cursor.getString(2)));
          e.setEventLocation(cursor.getString(4));
  
          String myDate = cursor.getString(5);
          e.setEventDate(parser.parse(myDate));
          e.setEventDescription(cursor.getString(6));
          e.setEventLink(cursor.getString(7));
  
  
          String myStartTime = cursor.getString(8);
          e.setEventStartTime(parseTime.parse(myStartTime));
  
          String myEndTime = cursor.getString(9);
          e.setEventEndTime(parseTime.parse(myEndTime));
  
  
          global.add(e);
  
  
          if (i &lt; numRows) {
  
              cursor.moveToPosition(i + 1);
          }
  
          if (i &gt; numRows) {
              cursor.moveToFirst();
          }
  
  
      }
      return global;
  }
  </code></pre>
  
  <p>I've also tried without a specific category search (as in just using the arraylist returned by my getAllEvents method) but i'm still getting a null pointer exception. I get a null pointer exception with getAllEvents and an empty/blank listview with getAllEventsCategory</p>
  
  <p>getAllEvents() method:</p>
  
  <pre><code>public ArrayList&lt;Event&gt; getAllEvents() throws ParseException {
      SQLiteDatabase dq = this.getReadableDatabase();
      ArrayList&lt;Event&gt; global = new ArrayList&lt;Event&gt;();
  
  
  
  
      Log.d("QUERY ", "" + query);
  
      Cursor cursor = dq.rawQuery(query, null);
      int numRows = cursor.getCount();
      cursor.moveToFirst();
  
     if(cursor.moveToFirst()){
         cursor.moveToFirst();
         //for loop to add each event to the arraylist
         for (int i = 0; i &lt; numRows; i++) {
             Event e = new Event();
  
             e.setEventID(Integer.parseInt(cursor.getString(0)));
             e.setEventName(cursor.getString(1));
             e.setSocietyID(Integer.parseInt(cursor.getString(2)));
             e.setEventLocation(cursor.getString(3));
  
             String myDate = cursor.getString(4);
             e.setEventDate(parser.parse(myDate));
             e.setEventDescription(cursor.getString(5));
             if(cursor.getString(6) != null) {
                 e.setEventLink(cursor.getString(6));
             }else{
                 e.setEventLink("");
             }
  
             String myStartTime = cursor.getString(7);
             e.setEventStartTime(parseTime.parse(myStartTime));
  
             Date date = new Date();
             date.setTime(0);
  
             if(cursor.getString(8) != null){
                 String myEndTime = cursor.getString(8);
                 e.setEventEndTime(parseTime.parse(myEndTime));
             }else{
                 e.setEventEndTime(date);
             }
  
  
  
             global.add(e);
  
  
             if (i &lt; numRows) {
  
                 cursor.moveToPosition(i + 1);
             }
  
             if (i &gt; numRows) {
                 cursor.moveToFirst();
             }
  
  
         }
  
     }else{
         Log.d("Results", "no results");
     }
      Log.d("Array size", "" + global.size());
      return global;
  }
  </code></pre>
  
  <p><a href="http://i.imgur.com/bGHndPo.png" rel="nofollow">This</a> is my logcat. the d log "Array size" is the size of the array that should be the parameter for the lv1.setAdapter() method</p>