title: Searching listview with custom ArrayAdapter
body: <p>I have a listview that has a custom adapter, and I was trying to make it searchable using an Action Item. When I click the search icon in the action bar, the edit text comes up, but when I enter text and click "done" on the keyboard, nothing happens.</p>
  
  <p>Here is the main class:</p>
  
  <pre><code>public class ItemId extends SherlockListActivity {
  
      EditText editsearch;
      ArrayAdapter&lt;String&gt; adapter;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          Context ctx = getApplication();
          Resources res = ctx.getResources();
  
          String[] options = res.getStringArray(R.array.item_ids);
          String[] ids = res.getStringArray(R.array.item_names);
          TypedArray icons = res.obtainTypedArray(R.array.item_images);
  
          adapter = new ItemIDAdapter(ctx, R.layout.idslistitem, ids, options, icons);
  
          setListAdapter(adapter );
      }
  
          @Override
          public boolean onCreateOptionsMenu(Menu menu) {
              // Get the options menu view from menu.xml in menu folder
              getSupportMenuInflater().inflate(R.menu.items_menu, menu);
  
              // Locate the EditText in menu.xml
              editsearch = (EditText) menu.findItem(R.id.menu_search).getActionView();
  
              // Capture Text in EditText
              editsearch.addTextChangedListener(textWatcher);
  
              // Show the search menu item in menu.xml
              MenuItem menuSearch = menu.findItem(R.id.menu_search);
  
              menuSearch.setOnActionExpandListener(new OnActionExpandListener() {
  
                  // Menu Action Collapse
                  @Override
                  public boolean onMenuItemActionCollapse(MenuItem item) {
                      // Empty EditText to remove text filtering
                      editsearch.setText("");
                      editsearch.clearFocus();
                      return true;
                  }
  
                  // Menu Action Expand
                  @Override
                  public boolean onMenuItemActionExpand(MenuItem item) {
                      // Focus on EditText
                      editsearch.requestFocus();
  
                      // Force the keyboard to show on EditText focus
                      InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                      imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
                      return true;
                  }
              });
  
              // Show the settings menu item in menu.xml
              MenuItem menuSettings = menu.findItem(R.id.home);
  
              // Capture menu item clicks
              menuSettings.setOnMenuItemClickListener(new OnMenuItemClickListener() {
  
                  @Override
                  public boolean onMenuItemClick(MenuItem item) {
                      Intent intent2 = new Intent(ItemId.this, Home.class);
                      startActivity(intent2);
                      return true;
                  }
  
              });
  
              return true;
          }
  
          // EditText TextWatcher
          private TextWatcher textWatcher = new TextWatcher() {
  
              @Override
              public void afterTextChanged(Editable s) {
                  // TODO Auto-generated method stub
                  String text = editsearch.getText().toString()
                          .toLowerCase(Locale.getDefault());
                  adapter.getFilter().filter(text);
              };
  
  
              @Override
              public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                      int arg3) {
                  // TODO Auto-generated method stub
  
              }
  
              @Override
              public void onTextChanged(CharSequence arg0, int arg1, int arg2,
                      int arg3) {
                  // TODO Auto-generated method stub
  
              }
  
          };
  }
  </code></pre>
  
  <p>And here is the Adapter class:</p>
  
  <pre><code>public class ItemIDAdapter extends ArrayAdapter&lt;String&gt; implements Filterable {
  
      public LayoutInflater mInflater;
  
      public String[] mStrings;
      public String[] mIds;
      public TypedArray mIcons;   
      public int mViewResourceId;
  
      public ItemIDAdapter(Context ctx, int viewResourceId,
              String[] strings, String[] ids, TypedArray icons) {
          super(ctx, viewResourceId, strings);
  
          mInflater = (LayoutInflater)ctx.getSystemService(
                  Context.LAYOUT_INFLATER_SERVICE);
  
          mStrings = strings;
          mIds = ids;
          mIcons = icons;       
          mViewResourceId = viewResourceId;
      }
  
      @Override
      public int getCount() {
          return mStrings.length;
      }
  
      @Override
      public String getItem(int position) {
          return mStrings[position];
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
  
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          convertView = mInflater.inflate(mViewResourceId, null);
  
          ImageView iv = (ImageView)convertView.findViewById(R.id.option_icon);
          iv.setImageDrawable(mIcons.getDrawable(position));
  
          TextView tv = (TextView)convertView.findViewById(R.id.option_text);
          tv.setText(mStrings[position]);
  
          TextView tv1 = (TextView)convertView.findViewById(R.id.itemids);
          tv1.setText(mIds[position]);
  
          return convertView;
      }
  
  
  }
  </code></pre>
  
  <p>If anyone has any idea as to why nothing happens when I search, or knows how to fix it, it'd be greatly appreciated. Thanks!!</p>