0

I have a request. I wanna, When I write something in SearchView, I want to open a ListView.. thanks and sorry for my bad english..

my app screnshot: https://i.stack.imgur.com/Ty0ok.png

I have only MainActivity.java Code:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);

    setContentView(R.layout.activity_main);
    mStatusView = (TextView) findViewById(R.id.status_text);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.searchview_in_menu, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    mSearchView = (SearchView) searchItem.getActionView();
    setupSearchView(searchItem);

    return true;
}

private void setupSearchView(MenuItem searchItem) {

    if (isAlwaysExpanded()) {
        mSearchView.setIconifiedByDefault(false);
    } else {
        searchItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM
                | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    }

    mSearchView.setOnQueryTextListener(this);
}

public boolean onQueryTextChange(String newText) {
    mStatusView.setText("Query = " + newText);
    return false;
}

public boolean onQueryTextSubmit(String query) {
    mStatusView.setText("Query = " + query + " : submitted");
    return false;
}

public boolean onClose() {
    mStatusView.setText("Closed!");
    return false;
}

protected boolean isAlwaysExpanded() {
    return false;
}

and i have a menu xml code. Thanks for help guys..

  • Your answer is may be http://stackoverflow.com/questions/21585326/implementing-searchview-in-action-bar . Hopefully this will work for you. – Chitrang Sep 28 '14 at 03:43
  • big thanks bro i will try again.. but this example's have problem. i already try. look pls: http://i.stack.imgur.com/d7t3A.png – Medet Bizimyer Sep 28 '14 at 03:47

1 Answers1

0

What i unsersttod from your question is, you need an auto complete for your searchview...

please check the following link for an example of what you are looking for...hope it will help you

http://androidforbeginner.blogspot.in/2012/09/expanded-search-view-in-android.html

thank you

Sam
  • 4,046
  • 8
  • 31
  • 47