コード例 #1
0
  private boolean searchForSearchResults(Spinner spinner, String query) {
    ArrayAdapter<String> spinneradapter = (ArrayAdapter<String>) spinner.getAdapter();
    ViewTypeSpinnerOnItemSelectedListener onItemClickListener =
        (ViewTypeSpinnerOnItemSelectedListener) spinner.getOnItemSelectedListener();

    for (int i = 0; i < spinneradapter.getCount(); i++) {
      String sname = onItemClickListener.getViewType(i).getName();
      String lname = onItemClickListener.getViewType(i).getLongName();
      if (sname.equalsIgnoreCase(query)) {
        Log.d("basti", "result: " + sname);
        onItemClickListener.fireEvent(i);
        return true;
      }
      if (query.length() > 4 && lname.toLowerCase().contains(query.toLowerCase())) {
        Log.d("basti", "result: " + lname);
        onItemClickListener.fireEvent(i);
        return true;
      }
    }
    return false;
  }