Is it possible to implement a search in the array for the text typed in EditText? In the adapter, I have a filter that finds the typed text in an ArrayList, creates a new ArrayList, and inserts data there

public void filter(String query) { mFilteredCheeses = new ArrayList<>(); for (String cheese : mDefaultCheeses) { if(cheese.toLowerCase().contains(query.toLowerCase())) { mFilteredCheeses.add(cheese); } } notifyDataSetChanged(); } 

Can I do the same thing, but with an array of String []

  • It is possible, but not necessary. Why do you need it? \ - YurySPb
  • Well, if you end up with an array, you can try using the toArray method in the list with the parameter something like new String[mFilteredCheeses.size()] - I. Smirnov
  • YuriySPb I want to understand everything, with the addition to the favorites and with filters. I have already created two adapters, the first for the favorites, the second for the filter. I want to combine all this and experiment with the code, I think it may be better to fill the list from the array. Dunno already tortured with this code. It seems to be an elementary task, which almost every second program encounters and cannot find a normal solution at all - Artsait
  • @Artsait, if you don’t know exactly what an array would be in a better case than a list, then always use a list. An array will not help you here - YuriySPb

0