title: setOnItemClickListener within Custom Adapter
body: <p>This is the error I receive:</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setOnItemClickListener(android.widget.AdapterView$OnItemClickListener)' on a null object reference
  </code></pre>
  
  <p>Why can't I do something like this? I've pasted the <code>View</code> class that exists within my custom <code>Adapter</code> class:</p>
  
  <pre><code>@Override
      public View getView(final int position, View convertView, ViewGroup parent) {
          ViewHolder holder;
  
          if (convertView == null) {
              convertView = LayoutInflater.from(mContext).inflate(R.layout.notifications_listview_item, null);
              holder = new ViewHolder();
              holder.username = (TextView)convertView.findViewById(R.id.username);
              holder.notificationText = (TextView)convertView.findViewById(R.id.notificationText);
              holder.time = (TextView)convertView.findViewById(R.id.time);
              holder.profilePicture = (ImageView) (convertView.findViewById(R.id.profilePicture));
              holder.notificationsIcon = (ImageView) (convertView.findViewById(R.id.notificationsIcon));
  
              convertView.setTag(holder);
          } else {
              holder = (ViewHolder)convertView.getTag();
          }
  
          final ParseObject notifications = mNotifications.get(position);
  
          Date createdAt = notifications.getCreatedAt();
          long now = new Date().getTime();
          String convertedDate = DateUtils.getRelativeTimeSpanString(createdAt.getTime(), now, DateUtils.SECOND_IN_MILLIS).toString();
  
          holder.username.setText(notifications.getString(ParseConstants.KEY_SENDER_NAME));
          holder.notificationText.setText(notifications.getString(ParseConstants.KEY_NOTIFICATION_TEXT));
          holder.time.setText(convertedDate);
          holder.profilePicture = (ImageView)convertView.findViewById(R.id.profilePicture);
  
          if (notifications.getString(ParseConstants.KEY_NOTIFICATION_TYPE).equals(ParseConstants.TYPE_LIKE)) {
              holder.notificationsIcon.setImageResource(R.drawable.ic_action_like_feed_full);
          }
  
          if (notifications.getString(ParseConstants.KEY_NOTIFICATION_TYPE).equals(ParseConstants.TYPE_CYCLE)) {
              holder.notificationsIcon.setImageResource(R.drawable.ic_not_saved);
          }
  
          if (notifications.getString(ParseConstants.KEY_NOTIFICATION_TYPE).equals(ParseConstants.TYPE_EDIT)) {
              holder.notificationsIcon.setImageResource(R.drawable.ic_action_edit_feed);
          }
  
          holder.username.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  startGalleryActivity(notifications.getString(ParseConstants.KEY_SENDER_ID));
              }
          });
  
          holder.profilePicture.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  startGalleryActivity(notifications.getString(ParseConstants.KEY_SENDER_ID));
              }
          });
  
          holder.notificationsIcon.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent intent = new Intent(mContext, FeedActivitySingle.class);
                  intent.putExtra(FeedActivitySingle.EXTRA_DESIGN, notifications.getString(ParseConstants.KEY_SENDER_FEED_OBJECT_ID));
                  mContext.startActivity(intent);
              }
          });
  
          ListView listView = (ListView)convertView.findViewById(android.R.id.list);
  
              listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
                  @Override
                  public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                      Intent intent = new Intent(mContext, FeedActivitySingle.class);
                      intent.putExtra(FeedActivitySingle.EXTRA_DESIGN, notifications.getString(ParseConstants.KEY_SENDER_FEED_OBJECT_ID));
                      mContext.startActivity(intent);
                  }
              });
  
          return convertView;
      }
  </code></pre>
  
  <p>I want to set an <code>onItemClickListener</code> on one of the <code>listView</code> items in the Adapter. Why can't I do this? The error is thrown here where I've defined the <code>listView</code>: </p>
  
  <pre><code>ListView listView = (ListView)convertView.findViewById(android.R.id.list);
  </code></pre>
  
  <p>What should I do? All the regular ClickListeners work but I want the user to be able to select the <code>listView</code> item in the Adapter itself.</p>
  
  <p><strong>Edit (Answer):</strong></p>
  
  <p>Problem resolved! Just had to put my <code>onItemClickListener</code> in the <code>onCreate</code> method of the main activity where the custom <code>Adapter</code> was initialized.</p>
  
  <pre><code>    ListView listView = (ListView)findViewById(android.R.id.list);
  
      listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              Toast.makeText(getApplicationContext(), "Voila! It works.", Toast.LENGTH_SHORT).show();
              List&lt;ParseObject&gt; notifications = adapter.getNotifications();
          }
      });
  </code></pre>