Example usage for android.view Menu findItem

List of usage examples for android.view Menu findItem

Introduction

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

Prototype

public MenuItem findItem(int id);

Source Link

Document

Return the menu item with a particular identifier.

Usage

From source file:com.adithya321.sharesanalysis.fragments.ShareSalesFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.share_sales, menu);
    actionProgressItem = menu.findItem(R.id.action_progress);
    actionRefreshItem = menu.findItem(R.id.action_refresh);
    actionProgressItem.setVisible(true);
    actionRefreshItem.setVisible(false);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.javierc.albuquerquenow.TransitMap.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.transit_map, menu);
    menu.findItem(R.id.offline_routes).setChecked(useOfflineRoutes);
    return true;//from   ww  w  .  ja v a  2 s . c  o m
}

From source file:com.mtomczak.nausicaa.MainActivity.java

@Override
public boolean onPreparePanel(int featureId, View view, Menu menu) {

    if (featureId == WindowUtils.FEATURE_VOICE_COMMANDS) {
        MenuItem status = menu.findItem(R.id.status_view_option);
        status.setVisible(currentSubview != NausicaaSubview.STATUS);
        status.setEnabled(currentSubview != NausicaaSubview.STATUS);

        MenuItem docking = menu.findItem(R.id.docking_view_option);
        docking.setVisible(currentSubview != NausicaaSubview.DOCKING);
        docking.setEnabled(currentSubview != NausicaaSubview.DOCKING);

        return true;
    }//  w ww . j  a va  2  s . c o m
    return super.onPreparePanel(featureId, view, menu);
}

From source file:ca.rmen.android.networkmonitor.app.log.LogActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    // Only show the menu item to clear filters if we have filters.
    menu.findItem(R.id.action_reset_filters).setVisible(NetMonPreferences.getInstance(this).hasColumnFilters());
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.dvdprime.mobile.android.ui.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main_menu, menu);

    View count = menu.findItem(R.id.menu_badge).getActionView();
    badgeCount = (Button) count.findViewById(R.id.badge_count);
    badgeCount.setText(String.valueOf(0));
    badgeCount.setOnClickListener(new OnClickListener() {

        @Override/*www  .  j av  a2  s .  c o m*/
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, NotificationListActivity.class));
        }
    });

    return true;
}

From source file:com.sharedcab.batchcar.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    // If the nav drawer is open, hide action items related to the content view
    boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
    menu.findItem(R.id.action_settings).setVisible(!drawerOpen);
    return super.onPrepareOptionsMenu(menu);
}

From source file:br.com.bioscada.apps.biotracks.MarkerListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.marker_list, menu);
    insertMarkerMenuItem = menu.findItem(R.id.marker_list_insert_marker);
    searchMenuItem = menu.findItem(R.id.marker_list_search);
    ApiAdapterFactory.getApiAdapter().configureSearchWidget(this, searchMenuItem, null);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.aboveware.actionbar.honeycomb.ActionBarHelperHoneycomb.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    mOptionsMenu = menu;//w  w w  .j a  v a2 s  .  c om
    MenuItem searchItem = menu.findItem(R.id.menu_search);
    if (searchItem != null) {
        final SearchView searchView = (SearchView) searchItem.getActionView();
        searchView.setIconifiedByDefault(false);
        searchView.setSubmitButtonEnabled(true);
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(String query) {
                return iDocument.searchSubmit(query);
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                return iDocument.search(newText);
            }
        });
    }
    boolean returnValue = super.onCreateOptionsMenu(menu);
    if (shouldBeRefreshing) {
        setRefreshActionItemState(true);
    }
    shouldBeRefreshing = false;
    return returnValue;
}

From source file:com.example.office.ui.calendar.EventFragment.java

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

    // This will be called as soon as user presses the attach menu item to attach image to current event
    menu.findItem(R.id.action_attach).setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.action_attach:
                mImagePicker.showAttachImageDialog();
                return true;

            default:
                return false;
            }//ww w  . j av a2 s  . c  om
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.f16gaming.pathofexilestatistics.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    MenuItem toggleItem = menu.findItem(R.id.menu_toggle);
    toggleItem.setTitle(showHardcore ? R.string.menu_normal : R.string.menu_hardcore);
    return true;//from w  w  w  .  java 2 s  .  c  o m
}