We help IT Professionals succeed at work.

Android app filter listview like Instagram

simone bruziches
simone bruziches used Ask the Experts™
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?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Experts Exchange Dev
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

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.