Android app filter listview like Instagram

I'm creating an Android app in which there is a listeview and the search is filtered through an EditText.

What I want to know is how does Instagram (for example) show the preview of searches divided into categories?

Let me explain better, if on Instagram I look for example "London" I will come out in a list of fields where for example there is the city icon and with the word "London" next to it, underneath there is a field with "#london" written on it and another field with "London" and the user's photo below.

What are the names of the searches divided into categories or sections in "Programming"?

I would like to do it in my App but the problem is that I don't know how to call this thing.

If I have a listview and want to filter it through a search, while I type the word "London" it immediately shows me the Items with the same name as "London", instead I want a search like that of Instagram where the results are filtered first categories and then when you click on the category it shows you the results.

What is the name of this practice?
Screenshot_20190512-105039_Chrome.jpg
simone bruzichesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michael ArciniegaExperts Exchange DevCommented:
Edit: On second thought it would be better for your backend to return a sorted list for you to display since it'll have more resources. Check out the section called "Sorting an ArrayList according to user defined criteria" for the java way of doing it.

You might be looking for data binning. Here's one way you might implement it in an app:

1. user submits search from the app
2. database returns one list of all results from every category
3. in the returned list, each item has a field called "category" that has one value like "tag", "place", "person", etc.
4. in the app's list display you define what the category display order should be. "First is 'person', then 'tag', then 'place'
5. Create a new list by going through each category in turn and filtering out the values that match and appending to the new list.

A quick example in javascript:
const fakeSearchResults = [
   {
      title: 'London Dude',
      category: 'person'
   },
   {
      title: 'London',
      category: 'place'
   },
   {
      title: 'londonFootball',
      category: 'tag'
   },
   {
      title: 'London Metro',
      category: 'place'
   },
];

const displayOrder = ['tag', 'person', 'place'];

let searchDisplayList = [];

displayOrder.forEach( category => {
   const filteredList = fakeSearchResults.filter( searchItem => searchItem.category === category);
   searchDisplayList = searchDisplayList.concat(filteredList);
});

console.log('List in order: ', searchDisplayList);

Open in new window

sortedList
Keep in mind though that things can get very inefficient on much larger lists if you're not careful. In my example it wastes time going through the whole list multiple times instead of decided which bin to put in on the first pass and stitching them together afterwards.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Smartphone Programming

From novice to tech pro — start learning today.