Search in sources :

Example 1 with SearchView

use of com.actionbarsherlock.widget.SearchView in project howabout-android by recomio.

the class MainActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getSupportMenuInflater();
    inflater.inflate(R.menu.main, menu);
    // Place an action bar item for searching.
    final SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
    searchView.setQueryHint("Search");
    searchView.setIconified(true);
    searchMenu = menu.getItem(0);
    searchMenu.setActionView(searchView).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View view, boolean queryTextFocused) {
            if (!queryTextFocused) {
                Log.d("searchMenu.collapseActionView();", Boolean.toString(searchMenu.collapseActionView()));
                searchView.setQuery("", false);
            }
        }
    });
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String searchKeyword) {
            Intent intent = new Intent(MainActivity.this, SearchedTrackListActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            Bundle bundle = new Bundle();
            bundle.putString("category", "music");
            bundle.putString("method", "search");
            bundle.putString("searchKeyword", searchKeyword);
            intent.putExtras(bundle);
            startActivity(intent);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return true;
        }
    });
    return super.onCreateOptionsMenu(menu);
}
Also used : SearchView(com.actionbarsherlock.widget.SearchView) MenuInflater(com.actionbarsherlock.view.MenuInflater) SearchedTrackListActivity(io.recom.howabout.category.music.activity.SearchedTrackListActivity) Bundle(android.os.Bundle) Intent(android.content.Intent) SearchView(com.actionbarsherlock.widget.SearchView) View(android.view.View)

Example 2 with SearchView

use of com.actionbarsherlock.widget.SearchView in project ActionBarSherlock by JakeWharton.

the class Issue659 method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getSupportMenuInflater();
    inflater.inflate(R.menu.issue659, menu);
    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    return true;
}
Also used : SearchView(com.actionbarsherlock.widget.SearchView) MenuInflater(com.actionbarsherlock.view.MenuInflater) SearchManager(android.app.SearchManager)

Example 3 with SearchView

use of com.actionbarsherlock.widget.SearchView in project base-adapter-helper by JoanZapata.

the class TwitterFragment method onSearch.

@OptionsItem(R.id.search)
protected void onSearch(final MenuItem item) {
    this.searchMenuItem = item;
    SearchView searchView = (SearchView) item.getActionView();
    searchView.setQueryHint(followingAccount);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            item.collapseActionView();
            onSearchSubmit(query);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return true;
        }
    });
}
Also used : SearchView(com.actionbarsherlock.widget.SearchView)

Example 4 with SearchView

use of com.actionbarsherlock.widget.SearchView in project little-bear-dictionary by daimajia.

the class GeneralActivity method onKeyDown.

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    SearchView searchView = null;
    switch(keyCode) {
        case KeyEvent.KEYCODE_SEARCH:
            if (mSlidingMenu.isMenuShowing()) {
                mSlidingMenu.toggle();
            }
            if (mCurrentShowID != R.id.search) {
                removerCurrentAndReplaceFragment(R.id.search, new QueryWordFragment(), false);
            }
            searchView = (SearchView) findViewById(android.R.id.inputArea);
            if (searchView != null)
                searchView.setIconified(false);
            return true;
        case KeyEvent.KEYCODE_MENU:
            mSlidingMenu.toggle();
            break;
        case KeyEvent.KEYCODE_BACK:
            if (mSlidingMenu.isMenuShowing()) {
                mSlidingMenu.toggle();
                return true;
            }
            searchView = (SearchView) findViewById(android.R.id.inputArea);
            if (searchView != null && searchView.isIconified() == false) {
                searchView.clearFocus();
                searchView.setIconified(true);
                return true;
            }
            boolean askQuite = PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean("quitetip", true);
            if (askQuite == true) {
                AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
                builder.setTitle(R.string.tips);
                builder.setMessage(R.string.quite_tips);
                builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                });
                builder.setNeutralButton(R.string.give_suggestion, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        UMFeedbackService.openUmengFeedbackSDK(GeneralActivity.this);
                    }
                });
                builder.setNegativeButton(R.string.cancel, null);
                builder.show();
            }
            break;
        default:
    }
    return super.onKeyDown(keyCode, event);
}
Also used : QueryWordFragment(com.zhan_dui.dictionary.fragments.QueryWordFragment) AlertDialog(org.holoeverywhere.app.AlertDialog) SearchView(com.actionbarsherlock.widget.SearchView) DialogInterface(android.content.DialogInterface) SuppressLint(android.annotation.SuppressLint)

Example 5 with SearchView

use of com.actionbarsherlock.widget.SearchView in project ActionBarSherlock by JakeWharton.

the class SearchViews method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    //Used to put dark icons on light action bar
    boolean isLight = SampleList.THEME == R.style.Theme_Sherlock_Light;
    //Create the search view
    SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
    searchView.setQueryHint("Search for countries…");
    searchView.setOnQueryTextListener(this);
    searchView.setOnSuggestionListener(this);
    if (mSuggestionsAdapter == null) {
        MatrixCursor cursor = new MatrixCursor(COLUMNS);
        cursor.addRow(new String[] { "1", "'Murica" });
        cursor.addRow(new String[] { "2", "Canada" });
        cursor.addRow(new String[] { "3", "Denmark" });
        mSuggestionsAdapter = new SuggestionsAdapter(getSupportActionBar().getThemedContext(), cursor);
    }
    searchView.setSuggestionsAdapter(mSuggestionsAdapter);
    menu.add("Search").setIcon(isLight ? R.drawable.ic_search_inverse : R.drawable.abs__ic_search).setActionView(searchView).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    return true;
}
Also used : SearchView(com.actionbarsherlock.widget.SearchView) MatrixCursor(android.database.MatrixCursor)

Aggregations

SearchView (com.actionbarsherlock.widget.SearchView)6 SuppressLint (android.annotation.SuppressLint)2 MenuInflater (com.actionbarsherlock.view.MenuInflater)2 SearchManager (android.app.SearchManager)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 Theme (android.content.res.Resources.Theme)1 MatrixCursor (android.database.MatrixCursor)1 Bundle (android.os.Bundle)1 TypedValue (android.util.TypedValue)1 View (android.view.View)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 ActionBar (com.actionbarsherlock.app.ActionBar)1 QueryWordFragment (com.zhan_dui.dictionary.fragments.QueryWordFragment)1 SearchedTrackListActivity (io.recom.howabout.category.music.activity.SearchedTrackListActivity)1 AlertDialog (org.holoeverywhere.app.AlertDialog)1