title: Searchview in Android working but displaying incorrect result when clicked on.
body: <p>So i have a custom adapter with a searchview. I got my searchview to display the correct results whenever I search for a particular person. But when I click on the item in the searchview it returns a result from the original list.</p>
  
  <p>So for example, I have items ab,cd,ef and i search for ef. The searchview returns the 1 item ef. But if I click on it, I will get the data for ab. </p>
  
  <p>How do I fix this? Or do i need to override a method for a onclick for the searchview? </p>
  
  <p>Thank you. (I will post my code (I will take out the nonrelated code), my custom adapter has the searchview code in it. The other is my fragment that contains my searchview and listview list).</p>
  
  <pre><code>My Custom Adapater. 
  
  
  
  public class oncallAdapter extends ArrayAdapter&lt;OnCallContact&gt; implements SectionIndexer
  {
      private ArrayList&lt;OnCallContact&gt; contactList;
      private Context context;
  
      //For our searchview
      private MyFilter filter;
      private ArrayList&lt;OnCallContact&gt; mcontactListFilter;
  
      //OUr adapter constructor
      //WE have an arraylist which represents the bulletin objects
      public oncallAdapter(ArrayList&lt;OnCallContact&gt; ONCALLLIST, Context ctx)
      {
          super(ctx, R.layout.list_item_oncall, ONCALLLIST);
          this.contactList = ONCALLLIST;
          this.context= ctx;
          this.mcontactListFilter = ONCALLLIST;
      }
  
      //This is what sets up the textviews or one item in the listview.
      //We are overiding the orignial method
      @Override
      public View getView(int position, View convertView, ViewGroup parent)
      {
          //if null then inflate the view which is the row for the bulletins
          if(convertView == null)
          {
              LayoutInflater inflator = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = inflator.inflate(R.layout.list_item_oncall,parent,false);
          }
  
  
  
          TextView mgroup = (TextView) convertView.findViewById(R.id.oncall_group);
          TextView mname = (TextView) convertView.findViewById(R.id.oncall_name);
          TextView mCircleText = (TextView) convertView.findViewById(R.id.circleText);
  
          OnCallContact b = contactList.get(position);
  
  
          //Setting the textviews.
          mgroup.setText(b.getMgroup());
          mname.setText(b.getMname());
          mCircleText.setText(b.getMgroup().substring(0,1).toUpperCase());
  
          return convertView;
      }
  
      @Override
      public android.widget.Filter getFilter()
      {
          if(filter == null)
          {
              filter = new MyFilter();
          }
  
          return filter;
      }
   private class MyFilter extends android.widget.Filter
   {
      @Override
      protected android.widget.Filter.FilterResults performFiltering(CharSequence constraint)
      {
        FilterResults results = new FilterResults();
  
          if(constraint!= null &amp;&amp; constraint.length()&gt;0)
          {
              //Arraylist where we will add the items (oncallConcacts) that have the letter
              ArrayList&lt;OnCallContact&gt; filterList = new ArrayList&lt;&gt;();
  
              for(int i=0; i &lt; mcontactListFilter.size();i++)
              {
                  //CHecking if the letter is in the name
                  if(mcontactListFilter.get(i).getMname().toUpperCase().contains(constraint.toString().toUpperCase()))
                  {
                      OnCallContact contact = new OnCallContact();
  
                      contact.setMname(mcontactListFilter.get(i).getMname());
                      contact.setMgroup(mcontactListFilter.get(i).getMgroup());
                      contact.setMtitle(mcontactListFilter.get(i).getMtitle());
                      contact.setMbusinessPhone(mcontactListFilter.get(i).getMbusinessPhone());
                      contact.setMemail(mcontactListFilter.get(i).getMemail());
                      contact.setMpager(mcontactListFilter.get(i).getMpager());
                      contact.setmManagerName(mcontactListFilter.get(i).getmManagerName());
                      contact.setmManagerBusinessPhone(mcontactListFilter.get(i).getmManagerBusinessPhone());
                      contact.setmManagerPager(mcontactListFilter.get(i).getmManagerPager());
                      contact.setmManagerEmail(mcontactListFilter.get(i).getmManagerEmail());
  
                      filterList.add(contact);
                  }
              }
  
              results.count = filterList.size();
              results.values = filterList;
  
              Log.v("HEre is the filtersize " , "" +filterList.size());
          }
  
          else
          {
              results.count = mcontactListFilter.size();
              results.values = mcontactListFilter;
          }
  
          return results;
      }
  
       @Override
       protected void publishResults(CharSequence constraint, FilterResults results)
       {
  
           contactList = (ArrayList&lt;OnCallContact&gt;) results.values;
           notifyDataSetChanged();
  
       }
  }
  
  }
  </code></pre>
  
  <p>My fragment class </p>
  
  <pre><code>  public class OnCallFragment extends android.support.v4.app.Fragment implements SearchView.OnQueryTextListener{
  
  oncallAdapter adapter;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.fragment_on_call, container, false);
  
      //Parsing the xml file and getting the data we need which is an arraylist of oncallContacts
      OnCallXMLParser b = new OnCallXMLParser();
      final ArrayList&lt;OnCallContact&gt; list = b.parse(getContext());
  
      //HEre the custom adapter is making the listviews
      adapter = new oncallAdapter(list, getContext());
      final ListView listView = (ListView) rootView.findViewById(R.id.onCallListView);
  
      SearchView search = (SearchView)rootView.findViewById(R.id.onCall_searchView);
      search.setOnQueryTextListener(this);
  
      //displaying the listview by setting the adapter.
      listView.setAdapter(adapter);
      listView.setFastScrollEnabled(true);
  
      listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              //The contact we are passing through. (Item that was clicked on)
              OnCallContact temp = list.get(position);
              // Intent i = new Intent(getActivity(), DetailActivity.class).putExtra("extra", ForecastAdapter.getItem(position));
              Intent i = new Intent(getActivity(), OnCallDetail.class).putExtra("ContactInformation", temp);
  
              startActivity(i);
          }
      });
  
      // Inflate the layout for this fragment
      return rootView;
  }
  
  @Override
  public boolean onQueryTextChange(String newText) {
      adapter.getFilter().filter(newText);
      return false;
  }
  
  @Override
  public boolean onQueryTextSubmit(String query) {
      return false;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Thank You!!</p>