/** * Search allCountriesList contains text and put result into selectedCountriesList * * @param text */ @SuppressLint("DefaultLocale") private void search(String text) { selectedCountriesList.clear(); for (Country country : allCountriesList) { if (country.getName().toLowerCase(Locale.ENGLISH).contains(text.toLowerCase())) { selectedCountriesList.add(country); } } adapter.notifyDataSetChanged(); }
/** Support sorting the countries list */ @Override public int compare(Country lhs, Country rhs) { return lhs.getName().compareTo(rhs.getName()); }