title: app crashes on notifyDataSetChanged() Using Filter
body: <p>i have ListView that contains spinner, an image and a TextView. Above this ListView I have an EditText where a user can type his required item name and all the related items has been shown in the ListView. My code is working till here but the problem is when i try to delete the last character the app just gone crashed. I think the listview is not refreshed properly. I have searched many answers but found nothing that relates to my problem so plz help me in that app carsh problem.</p>
  
  <p>Here is my code of getFilter in LazyAdapter that extends from BaseAdapter</p>
  
  <pre><code>@SuppressLint("DefaultLocale")
      public android.widget.Filter getFilter() {
  
          return new android.widget.Filter() {
  
              @SuppressLint("DefaultLocale")
              @Override
              protected FilterResults performFiltering(CharSequence constraint) {
                  FilterResults Result = new FilterResults();
                  // if constraint is empty return the original names
                  if (TextUtils.isEmpty(constraint)){
                      //Result.values = storedata;
                      Result.count = listDetails.size();
                      return Result;
                  }
  
                  ArrayList&lt;items&gt; Filtered_Names = new ArrayList&lt;items&gt;();
                  String filterString = constraint.toString().toLowerCase();
                  String filterableString;
  
                  for(int i = 0; i&lt;listDetails.size(); i++){
                       items searchdata = listDetails.get(i);
                      String title = searchdata.title();
                      String id = searchdata.id();
                      String imageUrl = searchdata.imageUrl();
                      String pprice = searchdata.pprice();
                      String shippingPrice = searchdata.shippingPrice();
                      String stock = searchdata.stock();
  
                      filterableString = title+" "+id+" "+imageUrl+" "+pprice+" "+shippingPrice+" "+status+" "+stitle+" "+stock+" 
                      if(filterableString.toLowerCase().contains(filterString)){
                      Filtered_Names.add(listDetails.get(i));
                      //Log.e("Added", String.valueOf(Filtered_Names.size()));
                      }
  
                      }
                  Result.values = Filtered_Names;
                  Result.count = Filtered_Names.size();
                  //Log.e("Results", Result.values.toString() + String.valueOf(Result.count));
                  return Result;
              }
  
              @Override
              protected void publishResults(CharSequence constraint,
                      FilterResults results) {
                  // TODO Auto-generated method stub
                   @SuppressWarnings("unchecked")
                  ArrayList&lt;items&gt; resultList =(ArrayList&lt;items&gt;) results.values;
      LazyAdapter.this.listDetails = resultList;
      LazyAdapter.this.notifyDataSetChanged();
              }
  
          };
  
      }
  </code></pre>
  
  <p>and here is the code in the Activity</p>
  
  <pre><code>inputSearch = (EditText) findViewById(R.id.inputsearch);
  if(adapter!=null){
  }
   inputSearch.addTextChangedListener(new TextWatcher() {
  
          @Override
          public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
  
              try{
                  ItemsActivity.this.adapter.getFilter().filter(cs.toString());  
              }catch(Exception e){
                  e.printStackTrace();
              }
  
          }
  
          @Override
          public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                  int arg3) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void afterTextChanged(Editable arg0) {
              // TODO Auto-generated method stub 
  
          }
      }); 
  </code></pre>
  
  <p>And here is what logcat says</p>
  
  <p>**</p>
  
  <pre><code>FATAL EXCEPTION: main
  java.lang.NullPointerException
  at com.example.itemspac.LazyAdapter.getCount(LazyAdapter.java:48)
  at android.widget.AdapterView$AdapterDataSetObserver.onChanged(AdapterView.java:778)
  at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:31)
  at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
  at com.example.itemspac.LazyAdapter$3.publishResults(LazyAdapterGifts.java:305)
  at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:282)
  </code></pre>
  
  <p>**</p>
  
  <p>And here is my getCount() Method</p>
  
  <pre><code>@Override
      public int getCount() {
          // TODO Auto-generated method stub
          return listDetails.size();
      }
  </code></pre>