Search in sources :

Example 41 with MenuInflater

use of android.view.MenuInflater in project FastAdapter by mikepenz.

the class EndlessScrollListActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu items for use in the action bar
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.search, menu);
    //search icon
    menu.findItem(R.id.search).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_search).color(Color.BLACK).actionBar());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        final SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(String s) {
                touchCallback.setIsDragEnabled(false);
                fastItemAdapter.filter(s);
                return true;
            }

            @Override
            public boolean onQueryTextChange(String s) {
                fastItemAdapter.filter(s);
                touchCallback.setIsDragEnabled(TextUtils.isEmpty(s));
                return true;
            }
        });
    } else {
        menu.findItem(R.id.search).setVisible(false);
    }
    return super.onCreateOptionsMenu(menu);
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Example 42 with MenuInflater

use of android.view.MenuInflater in project FastAdapter by mikepenz.

the class SampleActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);
    menu.findItem(R.id.item_add).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_plus_square).color(Color.BLACK).actionBar());
    menu.findItem(R.id.item_delete).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_minus_square).color(Color.BLACK).actionBar());
    menu.findItem(R.id.item_change).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_settings_square).color(Color.BLACK).actionBar());
    menu.findItem(R.id.item_move).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_format_valign_bottom).color(Color.BLACK).actionBar());
    return true;
}
Also used : MenuInflater(android.view.MenuInflater) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Example 43 with MenuInflater

use of android.view.MenuInflater in project FastAdapter by mikepenz.

the class SwipeListActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu items for use in the action bar
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.search, menu);
    //search icon
    menu.findItem(R.id.search).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_search).color(Color.BLACK).actionBar());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        final SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(String s) {
                touchCallback.setIsDragEnabled(false);
                fastItemAdapter.filter(s);
                return true;
            }

            @Override
            public boolean onQueryTextChange(String s) {
                fastItemAdapter.filter(s);
                touchCallback.setIsDragEnabled(TextUtils.isEmpty(s));
                return true;
            }
        });
    } else {
        menu.findItem(R.id.search).setVisible(false);
    }
    return super.onCreateOptionsMenu(menu);
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Example 44 with MenuInflater

use of android.view.MenuInflater in project zxingfragmentlib by mitoyarzun.

the class HistoryActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (historyManager.hasHistoryItems()) {
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.menu.history, menu);
    }
    return super.onCreateOptionsMenu(menu);
}
Also used : MenuInflater(android.view.MenuInflater)

Example 45 with MenuInflater

use of android.view.MenuInflater in project Android-Iconics by mikepenz.

the class MainActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu items for use in the action bar
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_main, menu);
    //
    menu.findItem(R.id.search).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_search).color(Color.WHITE).sizeDp(24).respectFontBounds(true));
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        final SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(String s) {
                search(s);
                return true;
            }

            @Override
            public boolean onQueryTextChange(String s) {
                search(s);
                return true;
            }

            private void search(String s) {
                mCurrentSearch = s;
                if (mDrawer != null) {
                    int count = 0;
                    for (ITypeface font : mFonts) {
                        int foundCount = 0;
                        if (font.getIcons() != null) {
                            for (String icon : font.getIcons()) {
                                if (icon.toLowerCase().contains(s.toLowerCase())) {
                                    foundCount++;
                                }
                            }
                        }
                        mDrawer.updateBadge(count, new StringHolder(foundCount + ""));
                        count++;
                    }
                }
                //filter out the current fragment
                if (mIconsFragment != null)
                    mIconsFragment.onSearch(s);
            }
        });
    } else {
        menu.findItem(R.id.search).setVisible(false);
    }
    MenuItem menuItem = menu.findItem(R.id.action_opensource);
    menuItem.setIcon(new IconicsDrawable(this, FontAwesome.Icon.faw_github).actionBar().color(Color.WHITE));
    return super.onCreateOptionsMenu(menu);
}
Also used : StringHolder(com.mikepenz.materialdrawer.holder.StringHolder) SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) ITypeface(com.mikepenz.iconics.typeface.ITypeface) MenuItem(android.view.MenuItem) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Aggregations

MenuInflater (android.view.MenuInflater)304 MenuItem (android.view.MenuItem)32 View (android.view.View)16 Intent (android.content.Intent)12 AdapterView (android.widget.AdapterView)12 SearchView (android.support.v7.widget.SearchView)11 PopupMenu (android.widget.PopupMenu)10 TextView (android.widget.TextView)10 Menu (android.view.Menu)9 IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)9 ListView (android.widget.ListView)8 SearchManager (android.app.SearchManager)6 Point (android.graphics.Point)5 AdapterContextMenuInfo (android.widget.AdapterView.AdapterContextMenuInfo)5 ImageView (android.widget.ImageView)5 MenuBuilder (com.android.internal.view.menu.MenuBuilder)5 ActionBar (android.app.ActionBar)4 Cursor (android.database.Cursor)4 MenuBuilder (android.support.v7.view.menu.MenuBuilder)4 SpannableString (android.text.SpannableString)4