Example usage for android.view Menu clear

List of usage examples for android.view Menu clear

Introduction

In this page you can find the example usage for android.view Menu clear.

Prototype

public void clear();

Source Link

Document

Remove all existing items from the menu, leaving it empty as if it had just been created.

Usage

From source file:com.best.ui.Otpdescdetail.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    System.out.println("in onPrepareOptionsMenu of stops.java");
    MenuInflater inflater = getMenuInflater();
    menu.clear();
    /*if((tripsDisplayed == false && tripsRouteDisplayed == false && searchResultDisplayed == false)||(tripsDisplayed==true && tripsRouteDisplayed == false))
    {/*  w  ww .j a  va2 s  . c om*/
    inflater.inflate(com.best.ui.R.menu.search, menu);
    return true;
    } */
    if (iterlistdisplayed == false && busRouteDisplayed == true && individualModePage == false) {
        inflater.inflate(com.best.ui.R.menu.onlymap, menu);
        return true;
    }
    return false;
}

From source file:org.spinsuite.view.T_Menu.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    menu.clear();
    inflater.inflate(R.menu.main_menu, menu);
    if (m_MenuType.equals(LookupMenu.SYNCHRONIZATION_MENU)) {
        MenuItem sync = menu.findItem(R.id.action_synchronization);
        //   Visible false for menu
        if (sync != null) {
            sync.setVisible(false);/* w  w  w  .java2s  . c  o m*/
        }
    }
    //   Get Item
    MenuItem item = menu.findItem(R.id.action_search);
    //   Search View
    final View searchView = SearchViewCompat.newSearchView(m_ctx);
    if (searchView != null) {
        //   Set Back ground Color
        int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
        EditText searchText = (EditText) searchView.findViewById(id);
        //   Set Parameters
        if (searchText != null)
            searchText.setTextAppearance(m_ctx, R.style.TextSearch);
        //   
        SearchViewCompat.setOnQueryTextListener(searchView, new OnQueryTextListenerCompat() {
            @Override
            public boolean onQueryTextChange(String newText) {
                if (m_Adapter != null) {
                    String mFilter = !TextUtils.isEmpty(newText) ? newText : null;
                    m_Adapter.getFilter().filter(mFilter);
                }
                return true;
            }
        });
        SearchViewCompat.setOnCloseListener(searchView, new OnCloseListenerCompat() {
            @Override
            public boolean onClose() {
                if (!TextUtils.isEmpty(SearchViewCompat.getQuery(searchView))) {
                    SearchViewCompat.setQuery(searchView, null, true);
                }
                return true;
            }

        });
        MenuItemCompat.setActionView(item, searchView);
    }
}

From source file:com.xengar.android.stocktracker.ui.DetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
        ViewParent vp = getView().getParent();
        if (vp instanceof CardView) {
            ((View) vp).setVisibility(View.VISIBLE);
        }//from ww w .  j  a  va 2  s  . co m

        // Read data fom the cursor and display it
        fillViewData(data);
        fillChart(data);
    }

    AppCompatActivity activity = (AppCompatActivity) getActivity();
    Toolbar toolbarView = (Toolbar) getView().findViewById(R.id.toolbar);
    if (null != toolbarView) {
        Menu menu = toolbarView.getMenu();
        if (null != menu)
            menu.clear();
        toolbarView.inflateMenu(R.menu.detailfragment);
        finishCreatingMenu(toolbarView.getMenu());
    }
}

From source file:com.flowzr.activity.AccountListFragment.java

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

From source file:com.odoo.addons.phonecall.PhoneCalls.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    menu.clear();
    inflater.inflate(R.menu.menu_phonecalls, menu);
    setHasSearchView(this, menu, R.id.menu_phonecall_search);

}

From source file:com.gabm.fancyplaces.ui.MainWindow.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();

    getMenuInflater().inflate(curState.curMenu, menu);

    Toolbar toolbar = (Toolbar) findViewById(R.id.main_window_toolbar);
    if (curState.curMenu == R.menu.menu_main_window_multi_select) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setTitle(getString(R.string.main_multi_selection_title));
        toolbar.setBackgroundColor(getResources().getColor(R.color.ColorPrimaryDark));
        int noOfChild = toolbar.getChildCount();
        View view;/*from   ww w  .  j a v  a2  s  .c o m*/

        // animate toolbar elements
        for (int i = 1; i < noOfChild; i++) {
            view = toolbar.getChildAt(i);
            view.setAlpha(0);
            view.setScaleY(0);
            view.setPivotY((float) 0.5 * view.getHeight());
            view.animate().setDuration(200).scaleY(1).alpha(1);
        }

    } else if (curState.curMenu == R.menu.menu_main_window) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        setDefaultTitle();
        toolbar.setBackgroundColor(getResources().getColor(R.color.ColorPrimary));
    }

    return super.onPrepareOptionsMenu(menu);
}

From source file:org.tigase.mobile.muc.MucRoomFragment.java

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

From source file:com.tune.news.fragment.EntriesListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear(); // This is needed to remove a bug on Android 4.0.3

    inflater.inflate(R.menu.entry_list, menu);

    if (EntryColumns.FAVORITES_CONTENT_URI.equals(mUri)) {
        menu.findItem(R.id.menu_refresh).setVisible(false);
    } else {/*from w ww . j a  v  a2  s .c o  m*/
        menu.findItem(R.id.menu_share_starred).setVisible(false);
    }

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:name.setup.dance.DanceStepApp.java

public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    if (mIsRunning) {
        menu.add(0, MENU_PAUSE, 0, R.string.pause).setIcon(android.R.drawable.ic_media_pause).setShortcut('1',
                'p');
    } else {/*from   w  ww  .  j  a v a2 s.  c  o m*/
        menu.add(0, MENU_RESUME, 0, R.string.resume).setIcon(android.R.drawable.ic_media_play).setShortcut('1',
                'p');
    }
    menu.add(0, MENU_RESET, 0, R.string.reset).setIcon(android.R.drawable.ic_menu_close_clear_cancel)
            .setShortcut('2', 'r');
    menu.add(0, MENU_SETTINGS, 0, R.string.settings).setIcon(android.R.drawable.ic_menu_preferences)
            .setShortcut('8', 's').setIntent(new Intent(this, Settings.class));
    menu.add(0, MENU_QUIT, 0, R.string.quit).setIcon(android.R.drawable.ic_lock_power_off).setShortcut('9',
            'q');
    return true;
}

From source file:org.tigase.mobile.bookmarks.BookmarksActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.bookmarks_menu, menu);
    return true;/*w w  w.j av a  2  s  .  com*/
}