Search in sources :

Example 76 with SearchView

use of android.support.v7.widget.SearchView in project SMSBlocker by sagarpawardev.

the class HomeActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    // Inflate menu to add items to action bar if it is present.
    inflater.inflate(R.menu.menu_home, menu);
    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        // Log Initiate
        private LogUtil log = new LogUtil(this.getClass().getName());

        @Override
        public boolean onQueryTextSubmit(String query) {
            final String methodName = "onQueryTextSubmit()";
            log.justEntered(methodName);
            log.returning(methodName);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            final String methodName = "onQueryTextChange()";
            log.justEntered(methodName);
            // It is just standard procedure to check length before firing query
            log.info(methodName, "Filtering List with Query: " + newText);
            adapter.getFilter(RVHomeAdapter.FILTER_TEXT).filter(newText);
            // Uncheck switch
            // Otherwise searching in UnreadOnly mode will show results form read as well
            switchUnread.setChecked(false);
            log.returning(methodName);
            return true;
        }
    });
    return true;
}
Also used : LogUtil(dev.sagar.smsblocker.tech.utils.LogUtil) SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) SearchManager(android.app.SearchManager)

Example 77 with SearchView

use of android.support.v7.widget.SearchView in project BookReader by JustWayward.

the class SearchActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_search, menu);
    // 在菜单中找到对应控件的item
    searchMenuItem = menu.findItem(R.id.action_search);
    searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            key = query;
            mPresenter.getSearchResultList(query);
            saveSearchHistory(query);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            if (TextUtils.isEmpty(newText)) {
                if (mListPopupWindow.isShowing())
                    mListPopupWindow.dismiss();
                initTagGroup();
            } else {
                mPresenter.getAutoCompleteList(newText);
            }
            return false;
        }
    });
    // 外部调用搜索,则打开页面立即进行搜索
    search(key);
    MenuItemCompat.setOnActionExpandListener(searchMenuItem, new // 设置打开关闭动作监听
    MenuItemCompat.OnActionExpandListener() {

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            initTagGroup();
            return true;
        }
    });
    return true;
}
Also used : MenuItemCompat(android.support.v4.view.MenuItemCompat) SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) MenuItem(android.view.MenuItem)

Example 78 with SearchView

use of android.support.v7.widget.SearchView in project BookReader by JustWayward.

the class ReadCHMActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_chm_reader, menu);
    // 在菜单中找到对应控件的item
    MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
    searchView.setOnCloseListener(new SearchView.OnCloseListener() {

        @Override
        public boolean onClose() {
            mWebView.clearMatches();
            return false;
        }
    });
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            mWebView.findAllAsync(newText);
            try {
                for (Method m : WebView.class.getDeclaredMethods()) {
                    if (m.getName().equals("setFindIsUp")) {
                        m.setAccessible(true);
                        m.invoke(mWebView, true);
                        break;
                    }
                }
            } catch (Exception ignored) {
            }
            return false;
        }
    });
    return true;
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem) Method(java.lang.reflect.Method) WebView(android.webkit.WebView) IOException(java.io.IOException)

Example 79 with SearchView

use of android.support.v7.widget.SearchView in project ToolBarLib by jjhesk.

the class BeastBarDemo_v1 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.general);
    Toolbar temp = (Toolbar) findViewById(R.id.toolbar);
    combar cBar = (combar) findViewById(R.id.social_bar_component);
    cBar.setShareContent("exiting news", "this is the bredf", "http://www.popbee.com");
    BeastBar.Builder bb = new BeastBar.Builder();
    bb.back(R.drawable.ic_m_back);
    bb.companyIcon(R.drawable.starz_logo);
    bb.background(R.drawable.actionbar_bg_dark_black);
    bb.search(R.drawable.ic_find_mg);
    bb.setToolBarTitleSize(R.dimen.tb_title);
    bb.defaultTitle("Wrtie Comment");
    bb.setFontFace(this, "Pacifico.ttf");
    bb.setToolBarTitleColor(R.color.amber_700);
    bb.enableLogoAnimation(false);
    toolbar = BeastBar.withToolbar(this, temp, bb);
    searchView = (MaterialSearchView) findViewById(R.id.cmarterialsearch);
    searchView.setVoiceSearch(true);
    searchView.setCursorDrawable(R.drawable.color_cursor_white);
    // searchView.setSuggestions(getSuggestions());
    searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            // searchSubmission(query);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            // Do some magic
            return false;
        }
    });
    // show title
    Button b1 = (Button) findViewById(R.id.b1);
    // how main bar
    Button b2 = (Button) findViewById(R.id.b2);
    // show search bar
    Button b3 = (Button) findViewById(R.id.b3);
    // other function
    Button b4 = (Button) findViewById(R.id.b4);
    b4.setText("show back");
    // other function
    Button b5 = (Button) findViewById(R.id.b5);
    b5.setText("remove back");
    // other function
    Button bx = (Button) findViewById(R.id.bxx);
    // other function
    Button bs = (Button) findViewById(R.id.b_search);
    // other function
    Button search_off = (Button) findViewById(R.id.search_off);
    // other function
    Button search_on = (Button) findViewById(R.id.search_on);
    bx.setText("close this App");
    b1.setOnClickListener(this);
    b2.setOnClickListener(this);
    b3.setOnClickListener(this);
    b4.setOnClickListener(this);
    b5.setOnClickListener(this);
    bx.setOnClickListener(this);
    bs.setOnClickListener(this);
    search_off.setOnClickListener(this);
    search_on.setOnClickListener(this);
    toolbar.setFindIconFunc(new ButtonCon());
}
Also used : Button(android.widget.Button) BeastBar(com.hkm.advancedtoolbar.V5.BeastBar) MaterialSearchView(com.hkm.advancedtoolbar.materialsearch.MaterialSearchView) com.hkm.advancedtoolbar.socialbar.combar(com.hkm.advancedtoolbar.socialbar.combar) Toolbar(android.support.v7.widget.Toolbar)

Example 80 with SearchView

use of android.support.v7.widget.SearchView in project ToolBarLib by jjhesk.

the class TestOfCandyBar method onCreate.

@SuppressLint("ResourceAsColor")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.general);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    try {
        worker = CandyBar.Builder.with(this).companyLogo(R.drawable.starz_logo).searchView(LayoutAsset.classic_3).searchBarEvents(new SimpleSearchCallBack() {

            @Override
            public void onKeySearchStartConfirm(String text) {
                Log.d("start", text);
            }

            @Override
            public void onKeySearchLetter(String text) {
                Log.d("start", text);
            }

            @Override
            public void onRestoreToNormal(ActionBar toolbar) {
                worker.showBack();
            }
        }).setNotifcationTextColor(R.color.main_background).setNotificationOffset(15).setNotificationDrawableId(R.drawable.notg).overrideIcons(R.mipmap.cross_grey, R.mipmap.ic_action_close, R.mipmap.crossmp).background(R.drawable.bottom_line).presetCountNotification(u).build(toolbar);
    } catch (Exception e) {
        e.printStackTrace();
    }
    // show title
    Button b1 = (Button) findViewById(R.id.b1);
    // how main bar
    Button b2 = (Button) findViewById(R.id.b2);
    // show search bar
    Button b3 = (Button) findViewById(R.id.b3);
    // other function
    Button b4 = (Button) findViewById(R.id.b4);
    // other function
    Button b5 = (Button) findViewById(R.id.b5);
    // other function
    Button bxx = (Button) findViewById(R.id.bxx);
    b1.setOnClickListener(this);
    b2.setOnClickListener(this);
    b3.setOnClickListener(this);
    b4.setOnClickListener(this);
    b5.setOnClickListener(this);
    bxx.setOnClickListener(this);
}
Also used : Button(android.widget.Button) ActionBar(android.support.v7.app.ActionBar) SimpleSearchCallBack(com.hkm.advancedtoolbar.V3.layout.SimpleSearchCallBack) SuppressLint(android.annotation.SuppressLint)

Aggregations

SearchView (android.support.v7.widget.SearchView)151 MenuItem (android.view.MenuItem)88 View (android.view.View)56 SearchManager (android.app.SearchManager)37 RecyclerView (android.support.v7.widget.RecyclerView)35 TextView (android.widget.TextView)26 MenuInflater (android.view.MenuInflater)24 ImageView (android.widget.ImageView)20 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)19 MenuItemCompat (android.support.v4.view.MenuItemCompat)18 Toolbar (android.support.v7.widget.Toolbar)16 SearchView (android.widget.SearchView)12 ArrayList (java.util.ArrayList)11 ViewGroup (android.view.ViewGroup)10 MaterialSearchView (com.miguelcatalan.materialsearchview.MaterialSearchView)10 Intent (android.content.Intent)9 ListView (android.widget.ListView)9 BindView (butterknife.BindView)9 AdapterView (android.widget.AdapterView)8 EditText (android.widget.EditText)8