title: Android SearchView not working in fragment
body: <p>I am trying to implement a searchview that is only required in one fragment.  It will filter on a listview. </p>
  
  <pre><code>import android.os.Bundle;
  import android.app.Fragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.SearchView;
  import android.widget.SimpleAdapter;
  import com.alcontrol.atmis.anticimex.R;
  import com.alcontrol.atmis.anticimex.model.ListViewsModel;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  
  public class SalesParts extends Fragment {
  
  public SalesParts() {
      // Required empty public constructor
  }
  ArrayList&lt;ListViewsModel&gt; listofOrderSelectedArray = new ArrayList&lt;ListViewsModel&gt;();
  ArrayList&lt;ListViewsModel&gt; listofOrdersArray = new ArrayList&lt;ListViewsModel&gt;();
  SimpleAdapter adapter;
  ArrayAdapter arrayAdapter2;
  ListView mListView;
  ArrayList&lt;HashMap&lt;String, Object&gt;&gt; items;
  
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
  
      listofOrdersArray.add(new ListViewsModel(101, "Order Title 1",""));
      listofOrdersArray.add(new ListViewsModel(102, "Order Title 2",""));
      listofOrdersArray.add(new ListViewsModel(103, "Order Title 3",""));
      listofOrdersArray.add(new ListViewsModel(104, "Order Title 4",""));
      listofOrdersArray.add(new ListViewsModel(105, "Order Title 5",""));
      listofOrdersArray.add(new ListViewsModel(106, "Order Title 6",""));
      listofOrdersArray.add(new ListViewsModel(107, "Order Title 7",""));
      listofOrdersArray.add(new ListViewsModel(108, "Order Title 8",""));
      listofOrdersArray.add(new ListViewsModel(109, "Order Title 9",""));
      listofOrdersArray.add(new ListViewsModel(110, "SOrder Title 10",""));
  
      mListView = (ListView) getActivity().findViewById(R.id.salespartsList);
      mListView.setTextFilterEnabled(true);
  
      SearchView mSearchView = (SearchView) getActivity().findViewById(R.id.typeFindSalesPart);
      mSearchView.setIconifiedByDefault(false);
      mSearchView.setOnQueryTextListener(this);
      mSearchView.setSubmitButtonEnabled(false);
  
  
      items = new ArrayList&lt;HashMap&lt;String, Object&gt;&gt;();
      HashMap&lt;String, Object&gt; listItem;
  
      for (int i = 0; i &lt; listofOrdersArray.size(); i++) {
          ListViewsModel selectedDescription = listofOrdersArray.get(i);
          listItem = new HashMap&lt;String, Object&gt;();
          listItem.put("itemTitle",selectedDescription.itemTitle);
          listItem.put("itemID",selectedDescription.itemId);
          listItem.put("addBtn", "");
          items.add(listItem);
      }
  
      ListView addSelectedItems = (ListView) getActivity().findViewById(R.id.salespartsListSelected);
      arrayAdapter2 = new ArrayAdapter(getActivity(),R.layout.selected_salespart_item,R.id.itemTitle, listofOrderSelectedArray) {
  
          @Override
          public View getView(final int position, View convertView, ViewGroup parent) {
              View view = super.getView(position, convertView, parent);
  
              // get filled view from SimpleAdapter
              View itemView = super.getView(position, convertView, parent);
              // find our button there
              View addButton = itemView.findViewById(R.id.itemDeleteBtn);
  
              // set a tag to get button position in array (used to get values when button is clicked
              addButton.setTag(String.valueOf(position));
  
              // add an onClickListener
              addButton.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      String tagName = (String) v.getTag();
                      int arrayPosition = Integer.valueOf(tagName);
  
                      //remove selected item from the list of sales parts to choose from
                      listofOrderSelectedArray.remove(arrayPosition);
                      arrayAdapter2.notifyDataSetChanged();
                  }
              });
  
              return itemView;
          }
      };
      addSelectedItems.setAdapter(arrayAdapter2);
  
      adapter = new SimpleAdapter(getActivity(), items, R.layout.salespart_item, new String[]{"itemTitle", "addBtn"}, new int[]{R.id.itemTitle, R.id.itemAddBtn}) {
  
          @Override
          public View getView(final int position, View convertView, ViewGroup parent) {
              View view = super.getView(position, convertView, parent);
  
              // get filled view from SimpleAdapter
              View itemView = super.getView(position, convertView, parent);
              // find our button there
              View addButton = itemView.findViewById(R.id.itemAddBtn);
  
              // set a tag to get button position in array (used to get values when button is clicked
              addButton.setTag(String.valueOf(position));
  
              // add an onClickListener
              addButton.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      String tagName = (String) v.getTag();
                      int arrayPosition = Integer.valueOf(tagName);
                      String title =listofOrdersArray.get(arrayPosition).itemTitle;
                      int id =listofOrdersArray.get(arrayPosition).itemId;
  
                      // add selected item to list of selected sales parts
                      listofOrderSelectedArray.add(new ListViewsModel(id, title, ""));
                      arrayAdapter2.notifyDataSetChanged();
                  }
              });
  
              return itemView;
          }
      };
      mListView.setAdapter(adapter);
  
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) { 
      // Inflate the layout for this fragment
      return inflater.inflate(R.layout.fragment_sales_parts, container, false);
  }
  }
  </code></pre>
  
  <p>I have placed the above code in 'OnActivityCreated' I am getting an error on the setOnQueryTextListener(this) line.  I have tried changing 'this' to getActivity() and getView() and neither have resolved the problem.</p>