title: Application crashes after returing to a previously invisible View in ListView
body: <p>I have a ListView with a following problem: When ListView is initialised, everything is OK, when I scroll down to see new Views that were not visible it's still OK, but when I scroll up the see the View that used to be visible, but was then made invisible by scrolling (it was "pushed" off the screen as the user went through the ListView) the whole application crashed and I get a NullPointerException. Not sure why this happens, any help would be greatly appreciated</p>
  
  <p>EDIT:
  The problem seems to be with the convertView</p>
  
  <p>ListView adapter:</p>
  
  <pre><code>public class EventListArrayAdapter extends ArrayAdapter&lt;String&gt; {
  Context context;
  ArrayList&lt;Venue&gt; values;
  Typeface aileronLight;
  
  public EventListArrayAdapter(Context context, ArrayList&lt;Venue&gt; values) {
      super(context, R.layout.single_event_list_item);
      this.context = context;
      this.values = values;
      aileronLight = Typeface.createFromAsset(context.getAssets(), "fonts/Aileron-Light.otf");
  }
  
  @Override
  public int getCount() {
      return values.size() + 1;
  }
  
  public View getView(int position, View convertView, ViewGroup parent) {
      View v = null;
  
      if(convertView==null){
          LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          v = inflater.inflate(R.layout.single_event_list_item, null);
      }
      else{
          v = convertView;
      }
  
      if (position == values.size()) {
          LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          v = inflater.inflate(R.layout.last_single_event_list_item, null);
          TextView noMoreResults = (TextView) v.findViewById(R.id.noMoreResults);
          Button changeSearch = (Button) v.findViewById(R.id.changeSearchButton);
          Button exitApp = (Button) v.findViewById(R.id.exitAppButton);
          noMoreResults.setTypeface(this.aileronLight);
          changeSearch.setTypeface(this.aileronLight);
          exitApp.setTypeface(this.aileronLight);
      } else {
          Venue currEvent = values.get(position);
          if (currEvent != null) {
              TextView singleItemTitle = (TextView) v.findViewById(R.id.singleItemTitle);
              TextView singleItemLocation = (TextView) v.findViewById(R.id.singleItemLocation);
              TextView singleItemDate = (TextView) v.findViewById(R.id.singleItemDate);
              singleItemTitle.setTypeface(aileronLight);
              singleItemLocation.setTypeface(aileronLight);
              singleItemDate.setTypeface(aileronLight);
  
              singleItemTitle.setText(currEvent.getName());
              singleItemDate.setText(currEvent.getDate());
              singleItemLocation.setText(currEvent.getLocation());
              AQuery aQuery = new AQuery(v);
              aQuery.id(R.id.singleItemImage).image(currEvent.getImageURL());
          }
      }
  
      return v;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Stack trace:</p>
  
  <pre><code>java.lang.NullPointerException
          at com.nightly.development.bussines.EventListArrayAdapter.getView(EventListArrayAdapter.java:72)
          at android.widget.AbsListView.obtainView(AbsListView.java:2285)
          at android.widget.ListView.makeAndAddView(ListView.java:1790)
          at android.widget.ListView.fillUp(ListView.java:725)
          at android.widget.ListView.fillGap(ListView.java:664)
          at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5424)
          at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3374)
          at android.widget.AbsListView.onTouchMove(AbsListView.java:3774)
          at android.widget.AbsListView.onTouchEvent(AbsListView.java:3583)
          at android.view.View.dispatchTouchEvent(View.java:7714)
          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2224)
          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2230)
          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1973)
          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2230)
          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1973)
          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2230)
          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1973)
          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2230)
          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1973)
          at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2151)
          at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1596)
          at android.app.Activity.dispatchTouchEvent(Activity.java:2502)
          at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2099)
          at android.view.View.dispatchPointerEvent(View.java:7894)
          at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4124)
          at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4003)
          at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
          at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3499)
          at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
          at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476)
          at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
          at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3499)
          at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
          at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3575)
          at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476)
          at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3632)
          at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
          at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3499)
          at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
          at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476)
          at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
          at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5819)
          at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5799)
          at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5770)
          at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5935)
          at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
          at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
          at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
          at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:5881)
          at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:5954)
          at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
          at android.view.Choreographer
  </code></pre>