Example usage for android.view MenuInflater inflate

List of usage examples for android.view MenuInflater inflate

Introduction

In this page you can find the example usage for android.view MenuInflater inflate.

Prototype

public void inflate(@MenuRes int menuRes, Menu menu) 

Source Link

Document

Inflate a menu hierarchy from the specified XML resource.

Usage

From source file:com.github.chenxiaolong.dualbootpatcher.appsharing.AppListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.actionbar_app_list, menu);

    final MenuItem item = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) item.getActionView();
    searchView.setOnQueryTextListener(this);

    if (mSearchQuery != null) {
        searchView.setIconified(false);//from   w w  w. j a va  2s  . c o  m
        //item.expandActionView();
        searchView.setQuery(mSearchQuery, false);
        searchView.clearFocus();
    }
}

From source file:com.google.zxing.client.android.history.HistoryActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (historyManager.hasHistoryItems()) {
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.menu.history, menu);
    }//from w w  w .  j  a  v  a  2 s. com
    return super.onCreateOptionsMenu(menu);
}

From source file:pl.bcichecki.rms.client.android.fragments.OutboxMessagesListFragment.java

private void setUpActionModeOnListItems() {
    getListView().setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    getListView().setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {

        @Override// w ww .j a  v  a2 s  .c  o m
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            return performAction(mode, item);
        }

        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.fragment_outbox_messages_list_context, menu);
            return true;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {
        }

        @Override
        public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
            if (checked) {
                verifyMenuItems(mode.getMenu());
                for (int i = 0; i < getListView().getCheckedItemPositions().size(); i++) {
                    if (i != position) {
                        getListView().setItemChecked(i, false);
                    }
                }
            }
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        private void verifyMenuItems(Menu menu) {
            Message checkedMessage = getFirstCheckedItem();
            menu.findItem(R.id.fragment_outbox_messages_list_context_menu_archive)
                    .setVisible(!checkedMessage.isArchivedBySender());
        }
    });
}

From source file:pl.bcichecki.rms.client.android.fragments.InboxMessagesListFragment.java

private void setUpActionModeOnListItems() {
    getListView().setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    getListView().setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {

        @Override//from   ww  w . j a  v  a  2 s .co m
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            return performAction(mode, item);
        }

        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.fragment_inbox_messages_list_context, menu);
            return true;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {
        }

        @Override
        public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
            if (checked) {
                verifyMenuItems(mode.getMenu());
                for (int i = 0; i < getListView().getCheckedItemPositions().size(); i++) {
                    if (i != position) {
                        getListView().setItemChecked(i, false);
                    }
                }
            }
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        private void verifyMenuItems(Menu menu) {
            Message checkedMessage = getFirstCheckedItem();
            menu.findItem(R.id.fragment_inbox_messages_list_context_menu_archive)
                    .setVisible(!checkedMessage.isArchivedBySender());
        }
    });
}

From source file:br.com.GUI.perfil.PerfilPersonal.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.perfil_personal, menu);
}

From source file:biz.wiz.android.wallet.ui.BlockListFragment.java

@Override
public void onListItemClick(final ListView l, final View v, final int position, final long id) {
    final StoredBlock storedBlock = adapter.getItem(position);

    activity.startActionMode(new ActionMode.Callback() {
        @Override/* w  w  w . ja  v a2 s.  c om*/
        public boolean onCreateActionMode(final ActionMode mode, final Menu menu) {
            final MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.blocks_context, menu);

            return true;
        }

        @Override
        public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) {
            mode.setTitle(Integer.toString(storedBlock.getHeight()));
            mode.setSubtitle(storedBlock.getHeader().getHashAsString());

            return true;
        }

        @Override
        public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
            switch (item.getItemId()) {
            case R.id.blocks_context_browse:
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(
                        Constants.EXPLORE_BASE_URL + "block/" + storedBlock.getHeader().getHashAsString())));

                mode.finish();
                return true;
            }

            return false;
        }

        @Override
        public void onDestroyActionMode(final ActionMode mode) {
        }
    });
}

From source file:de.Maxr1998.xposed.maxlock.ui.settings.appslist.AppListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.applist_menu, menu);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.toolbar_search));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override//from   w  w w  . j av a 2  s.  c om
        public boolean onQueryTextSubmit(String s) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            mAdapter.getFilter().filter(s);
            return true;
        }
    });
    filterIcon(menu.findItem(R.id.toolbar_filter_activated));
}

From source file:com.liquid.wallpapers.free.ScroidWallpaperGallery.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = new MenuInflater(this);
    menuInflater.inflate(R.menu.main_menu, menu);

    return true;/*from   w w w. java 2s . c om*/
}

From source file:samples.piggate.com.piggateCompleteExample.Activity_Logged.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu items for use in the action bar
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.action_bar_actions, menu);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.allthingsgeek.celljoust.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);
    return super.onCreateOptionsMenu(menu);
}