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:br.liveo.ndrawer.ui.fragment.MainFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // TODO Auto-generated method stub
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu, menu);

    //Select search item
    final MenuItem menuItem = menu.findItem(R.id.menu_search);
    menuItem.setVisible(true);/* w  w  w .  j a  v  a 2 s .c o  m*/

    SearchView searchView = (SearchView) menuItem.getActionView();
    searchView.setQueryHint(this.getString(R.string.search));

    ((EditText) searchView.findViewById(R.id.search_src_text))
            .setHintTextColor(getResources().getColor(R.color.nliveo_white));
    searchView.setOnQueryTextListener(onQuerySearchView);

    //menu.findItem(R.id.menu_add).setVisible(true);

    mSearchCheck = false;
}

From source file:com.krayzk9s.imgurholo.ui.AccountFragment.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  av a  2  s.  c  o m*/
        inflater.inflate(R.menu.main_dark, menu);
    menu.findItem(R.id.action_search).setVisible(true);
    menu.findItem(R.id.action_refresh).setVisible(true);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    mSearchView = (SearchView) searchItem.getActionView();
    mSearchView.setQueryHint("Lookup Users");
    SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            // Do nothing
            return true;
        }

        @Override
        public boolean onQueryTextSubmit(String query) {
            Log.d("searching", mSearchView.getQuery() + "");
            Intent intent = new Intent();
            intent.putExtra("username", mSearchView.getQuery().toString());
            intent.setAction(ImgurHoloActivity.ACCOUNT_INTENT);
            intent.addCategory(Intent.CATEGORY_DEFAULT);
            startActivity(intent);
            return true;
        }
    };
    mSearchView.setOnQueryTextListener(queryTextListener);
}

From source file:com.akop.bach.fragment.xboxlive.GamesFragment.java

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

    inflater.inflate(R.menu.xbl_game_list, menu);
}

From source file:com.money.manager.ex.reports.IncomeVsExpensesListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_report_income_vs_expenses, menu);
    // fix menu char
    MenuItem itemChart = menu.findItem(R.id.menu_chart);
    if (itemChart != null) {
        Activity activity = getActivity();
        if (activity instanceof IncomeVsExpensesActivity) {
            itemChart.setVisible(!((IncomeVsExpensesActivity) activity).mIsDualPanel);
        }/*  w w w .  j  a  v  a  2  s  .co  m*/
    }
}

From source file:com.anjalimacwan.fragment.NoteListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (getId() == R.id.noteViewEdit)
        inflater.inflate(R.menu.main, menu);
}

From source file:com.android.gallery3d2.ingest.IngestActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.ingest_menu_item_list_selection, menu);
    mMenuSwitcherItem = menu.findItem(R.id.ingest_switch_view);
    menu.findItem(R.id.import_items).setVisible(false);
    setSwitcherMenuState(mMenuSwitcherItem, mFullscreenPagerVisible);
    return true;/*ww w  . j av  a2  s . c o m*/
}

From source file:app.cloud9.com.cloud9.NoticeBoard.java

public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu items for use in the action bar

    mMenu = menu;//  w ww  .  ja  v  a2 s  . c om
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.search, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchMenuItem = menu.findItem(R.id.search_notice);
    android.support.v7.widget.SearchView searchView = (android.support.v7.widget.SearchView) menu
            .findItem(R.id.search_notice).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(true);
    searchView.setMaxWidth(3800);
    SearchView.SearchAutoComplete theTextArea = (SearchView.SearchAutoComplete) searchView
            .findViewById(R.id.search_src_text);
    theTextArea.setTextColor(Color.WHITE);//or any color that you want

    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setSubmitButtonEnabled(true);
    searchView.setOnQueryTextListener(this);

    return true;

}

From source file:com.orange.datavenue.ValueFragment.java

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

From source file:ca.rmen.android.poetassistant.main.reader.ReaderFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    Log.d(TAG, "onCreateOptionsMenu() called with: " + "menu = [" + menu + "], inflater = [" + inflater + "]");
    inflater.inflate(R.menu.menu_tts, menu);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        menu.findItem(R.id.action_new).setTitle(R.string.file_clear);
        menu.findItem(R.id.action_open).setVisible(false);
        menu.findItem(R.id.action_save).setVisible(false);
        menu.findItem(R.id.action_save_as).setVisible(false);
    }//  ww  w.j  a  v  a 2  s.c  o  m
}

From source file:de.geeksfactory.opacclient.frontend.OpacActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater mi = new MenuInflater(this);
    mi.inflate(R.menu.activity_opac, menu);
    return super.onCreateOptionsMenu(menu);
}