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.liquid.wallpapers.free.ScroidWallpaperGallery.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (this.selectedWallpaper == null || !(v instanceof Gallery)) {
        return;//from w w w. j av  a2  s .  c  o m
    }

    MenuInflater menuInflater = new MenuInflater(this);
    menuInflater.inflate(R.menu.gallery_context_menu, menu);

    if (this.favouriteDAO.isFavourite(this.selectedWallpaper.getId())) {
        menu.findItem(R.id.galleryRemoveFavouriteMenuItem).setVisible(true);
    } else {
        menu.findItem(R.id.galleryAddFavouriteMenuItem).setVisible(true);
    }
}

From source file:fr.cph.chicago.activity.BusActivity.java

@Override
public final boolean onCreateOptionsMenu(final Menu menu) {
    super.onCreateOptionsMenu(menu);
    this.mMenu = menu;

    // Inflate menu with no search
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_no_search, menu);

    // Modify action bar title
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle("Bus");

    // Load top bar animation
    MenuItem refreshMenuItem = menu.findItem(R.id.action_refresh);
    refreshMenuItem.setActionView(R.layout.progressbar);
    refreshMenuItem.expandActionView();/*from   ww  w  . j a  va 2 s. c o m*/

    return true;
}

From source file:com.androguide.honamicontrol.soundcontrol.SoundControlFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.sound_control, menu);
    SharedPreferences p = fa.getSharedPreferences("SOUND_CONTROL", 0);
    if (p.getBoolean("LINKED", true))
        menu.getItem(0).setChecked(true);
    else/*from   www  .  j av a  2s.c om*/
        menu.getItem(0).setChecked(false);
}

From source file:com.krayzk9s.imgurholo.ui.CommentsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    ImgurHoloActivity activity = (ImgurHoloActivity) getActivity();
    if (activity.getApiCall().settings.getString("theme", MainActivity.HOLO_LIGHT)
            .equals(MainActivity.HOLO_LIGHT))
        inflater.inflate(R.menu.main, menu);
    else/*from w  ww  . j a  v  a 2 s  .  com*/
        inflater.inflate(R.menu.main_dark, menu);
    menu.findItem(R.id.action_upload).setVisible(false);
    menu.findItem(R.id.action_refresh).setVisible(true);
}

From source file:es.uniovi.imovil.fcrtrainer.BaseExerciseFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.game_control, menu);
    MenuItem item = menu.findItem(R.id.action_change_game_mode);
    try {/*from w  ww  .j ava 2  s  .c o m*/
        MainActivity activity = (MainActivity) getActivity();
        if (item != null && activity != null) {
            item.setVisible(!activity.isDrawerOpen());
        }
    } catch (ClassCastException ex) {
        // El fragmento est incrustado en una actividad distinta a
        // MainActivity. No se hace nada
    }

    MenuItem setup = menu.findItem(R.id.action_settings);
    if (mIsPlaying) {
        item.setIcon(R.drawable.ic_action_stop);
        setup.setVisible(false);
    } else {
        item.setIcon(R.drawable.ic_action_play);
        setup.setVisible(true);
    }
}

From source file:jahirfiquitiva.iconshowcase.fragments.WallpapersFragment.java

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

From source file:de.baumann.hhsmoodle.data_random.Random_Fragment.java

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

From source file:aerizostudios.com.cropshop.MainActivity.java

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_main, menu);
    return true;//from   w w  w .j a va  2s. com
}

From source file:io.v.android.apps.syncslides.NavigationDrawerFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // If the drawer is open, show the global app actions in the action bar. See also
    // showGlobalContextActionBar, which controls the top-left area of the action bar.
    if (mDrawerLayout != null && isDrawerOpen()) {
        inflater.inflate(R.menu.global, menu);
        showGlobalContextActionBar();/*from w  w w  .  j a  va 2  s  .  c o m*/
    }
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.akhbulatov.wordkeeper.ui.fragment.WordListFragment.java

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

    MenuItem searchItem = menu.findItem(R.id.menu_search_word);
    SearchView searchView = (SearchView) searchItem.getActionView();

    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    searchView.setSearchableInfo(//from   ww  w .  j  a v  a  2  s.  c  o m
            searchManager.getSearchableInfo(new ComponentName(getActivity(), MainActivity.class)));
    searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            final Cursor cursor = mWordDbAdapter.getAll(sSortMode);
            final int column = cursor.getColumnIndex(WordEntry.COLUMN_NAME);
            if (newText.length() > 0) {
                mWordAdapter.swapCursor(new FilterCursorWrapper(cursor, newText, column));

                mTextEmptyWordList.setVisibility(View.GONE);
                if (mWordAdapter.getItemCount() == 0) {
                    String escapedNewText = TextUtils.htmlEncode(newText);
                    String formattedNoResults = String.format(getString(R.string.no_results_word),
                            escapedNewText);
                    CharSequence styledNoResults = Html.fromHtml(formattedNoResults);

                    mTextNoResultsWord.setText(styledNoResults);
                    mTextNoResultsWord.setVisibility(View.VISIBLE);
                } else {
                    mTextNoResultsWord.setVisibility(View.GONE);
                }
            } else {
                mWordAdapter.swapCursor(cursor);

                mTextNoResultsWord.setVisibility(View.GONE);
                if (mWordAdapter.getItemCount() == 0) {
                    mTextEmptyWordList.setVisibility(View.VISIBLE);
                }
            }
            return true;
        }
    });
}