-1

How to implement youtube app like search functionality in action Bar ,How it search strings dynamically from server.and display in list view. I have no idea how to add dynamic search feature in it , which response from server.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Adi
  • 400
  • 8
  • 25

3 Answers3

0

Step - 1

If you have more things for the search results then you have to implement onTextChange call to the server and retrieve the list as text change.

or

If you have small list you can retrive whole list onstarting of the activity.

Step - 2

set data in adapter of the AutoCompleteTextView.

Community
  • 1
  • 1
Keyur Lakhani
  • 4,321
  • 1
  • 24
  • 35
0

This is exactly what you looking for,Try to use MaterialSearchView

MaterialSearchView searchView = (MaterialSearchView) findViewById(R.id.search_view);
    searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String query) {
                //Do some magic
                return false;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                //Do some magic
                return false;
            }
        });

        searchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {
            @Override
            public void onSearchViewShown() {
                //Do some magic
            }

            @Override
            public void onSearchViewClosed() {
                //Do some magic
            }
        });
Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96
0

You can use this library.

Code:

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_search: {
                mSearchView.show(true/false); // animate, ONLY FOR MENU ITEM
                return true;
            }
            default:
                return super.onOptionsItemSelected(item);
        }
    }

XML:

<com.lapism.searchview.SearchView
    android:id="@+id/searchView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Styling SearchView:

       <attr name="search_version" format="enum">
           <enum name="toolbar" value="1000" />
           <enum name="menu_item" value="1001" />
       </attr>
       <attr name="search_version_margins" format="enum">
            <enum name="toolbar_small" value="2000" />
            <enum name="toolbar_big" value="2001" />
            <enum name="menu_item" value="2002" />
        </attr>
        <attr name="search_theme" format="enum">
            <enum name="light" value="3000" />
            <enum name="dark" value="3001" />
        </attr>
        <attr name="search_icon_color" format="color" />
        <attr name="search_background_color" format="color" />
        <attr name="search_text" format="string" />
        <attr name="search_text_color" format="color" />
        <attr name="search_text_size" format="dimension" />
        <attr name="search_hint" format="string" />
        <attr name="search_hint_color" format="color" />
        <attr name="search_divider" format="boolean" />
        <attr name="search_voice" format="boolean" />
        <attr name="search_voice_text" format="string" />
        <attr name="search_animation_duration" format="integer" />
        <attr name="search_shadow" format="boolean" />
        <attr name="search_shadow_color" format="boolean" />
        <attr name="search_elevation" format="dimension" />
prashant0205
  • 269
  • 1
  • 3
  • 17