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.gelakinetic.mtgfam.fragments.CardViewFragment.java

/**
 * Called when a registered view is long-pressed. The menu inflated will give different options based on the view class
 *
 * @param menu     The context menu that is being built
 * @param v        The view for which the context menu is being built
 * @param menuInfo Extra information about the item for which the context menu should be shown. This information
 *                 will vary depending on the class of v.
 *//* w w w  .j a  va2 s.  com*/
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {

    super.onCreateContextMenu(menu, v, menuInfo);

    TextView tv = (TextView) v;

    assert tv.getText() != null;
    mCopyString = tv.getText().toString();

    android.view.MenuInflater inflater = this.mActivity.getMenuInflater();
    inflater.inflate(R.menu.copy_menu, menu);
}

From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java

/**
 * Create the options menu that displays the refresh and about options
 *//*from  www .  ja v a  2  s  .  c o m*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (Constants.DEBUG) {
        MenuItem item = menu.add(getString(R.string.test_results));
        item.setIntent(new Intent(this, TestResultsTabActivity.class));
    }

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main, menu);
    return true;
}

From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.action_menu, menu);
    this.actionBarMenu = menu;

    title = getTitle(getCurrentFragmentName());
    refreshActionBar(getCurrentFragmentName());
    return true;//from  ww w  . jav a2  s  .c o m
    //return super.onCreateOptionsMenu(menu);
}

From source file:biz.bokhorst.xprivacy.ActivityApp.java

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    MenuInflater inflater = getMenuInflater();
    if (inflater != null && PrivacyService.checkClient()) {
        inflater.inflate(R.menu.app, menu);

        // Add all contact groups
        menu.findItem(R.id.menu_contacts).getSubMenu().add(-1, R.id.menu_contacts, Menu.NONE,
                getString(R.string.menu_all));

        // Add other contact groups in the background
        new AsyncTask<Object, Object, Object>() {
            @Override//from w w w  .ja  va 2 s .  co  m
            protected Object doInBackground(Object... arg0) {
                try {
                    String where = ContactsContract.Groups.GROUP_VISIBLE + " = 1";
                    where += " AND " + ContactsContract.Groups.SUMMARY_COUNT + " > 0";
                    Cursor cursor = getContentResolver().query(ContactsContract.Groups.CONTENT_SUMMARY_URI,
                            new String[] { ContactsContract.Groups._ID, ContactsContract.Groups.TITLE,
                                    ContactsContract.Groups.ACCOUNT_NAME,
                                    ContactsContract.Groups.SUMMARY_COUNT },
                            where, null,
                            ContactsContract.Groups.TITLE + ", " + ContactsContract.Groups.ACCOUNT_NAME);

                    if (cursor != null)
                        try {
                            while (cursor.moveToNext()) {
                                int id = cursor.getInt(cursor.getColumnIndex(ContactsContract.Groups._ID));
                                String title = cursor
                                        .getString(cursor.getColumnIndex(ContactsContract.Groups.TITLE));
                                String account = cursor
                                        .getString(cursor.getColumnIndex(ContactsContract.Groups.ACCOUNT_NAME));
                                menu.findItem(R.id.menu_contacts).getSubMenu().add(id, R.id.menu_contacts,
                                        Menu.NONE, title + "/" + account);
                            }
                        } finally {
                            cursor.close();
                        }
                } catch (Throwable ex) {
                    Util.bug(null, ex);
                }

                return null;
            }
        }.executeOnExecutor(mExecutor);

        return true;
    } else
        return false;
}

From source file:com.tweetlanes.android.view.TweetFeedFragment.java

@Override
public boolean configureOptionsMenu(MenuInflater inflater, Menu menu) {

    if (inflater != null && mContentHandle != null
            && (mContentHandle.getStatusesType() == StatusesType.USER_TIMELINE
                    || mContentHandle.getStatusesType() == StatusesType.USER_HOME_TIMELINE
                    || mContentHandle.getStatusesType() == StatusesType.USER_LIST_TIMELINE)) {

        if (getBaseLaneActivity() instanceof HomeActivity) {
            inflater.inflate(R.menu.home_tweet_feed_action_bar, menu);
        } else {/*  w w w  .  java2s.co  m*/
            inflater.inflate(R.menu.tweet_feed_action_bar, menu);
        }

        for (int i = 0; i < menu.size(); i++) {
            MenuItem menuItem = menu.getItem(i);
            if (menuItem.getItemId() == R.id.action_feed_filter) {
                SubMenu subMenu = menuItem.getSubMenu();
                if (subMenu != null) {
                    SocialNetConstant.Type socialNetType = getApp().getCurrentAccount().getSocialNetType();
                    int subMenuSize = subMenu.size();
                    for (int j = 0; j < subMenuSize; j++) {
                        MenuItem subMenuItem = subMenu.getItem(j);
                        switch (subMenuItem.getItemId()) {
                        case R.id.action_replies_visibility:

                            subMenuItem
                                    .setTitle(getString(getBaseLaneActivity().mStatusesFilter.getShowReplies()
                                            ? R.string.action_hide_replies
                                            : R.string.action_show_replies));
                            break;

                        case R.id.action_retweets_visibility:
                            subMenuItem
                                    .setTitle(getString(getBaseLaneActivity().mStatusesFilter.getShowRetweets()
                                            ? socialNetType == SocialNetConstant.Type.Twitter
                                                    ? R.string.action_hide_retweets
                                                    : R.string.action_hide_retweets_adn
                                            : socialNetType == SocialNetConstant.Type.Twitter
                                                    ? R.string.action_show_retweets
                                                    : R.string.action_show_retweets_adn));
                            break;

                        default:
                            break;
                        }

                    }
                }
            }
        }

        return true;
    }

    return false;
}

From source file:dev.memento.MainActivity.java

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

From source file:com.vegnab.vegnab.MainVNActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.vn_activity, menu);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.adafruit.bluefruit.le.connect.app.MainActivity.java

public void onClickFilterNameSettings(View view) {
    PopupMenu popup = new PopupMenu(this, view);
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override/*w ww.  j av  a  2s.c  o m*/
        public boolean onMenuItemClick(MenuItem item) {
            boolean processed = true;
            switch (item.getItemId()) {
            case R.id.scanfilter_name_contains:
                mPeripheralList.setFilterNameExact(false);
                break;
            case R.id.scanfilter_name_exact:
                mPeripheralList.setFilterNameExact(true);
                break;
            case R.id.scanfilter_name_sensitive:
                mPeripheralList.setFilterNameCaseInsensitive(false);
                break;
            case R.id.scanfilter_name_insensitive:
                mPeripheralList.setFilterNameCaseInsensitive(true);
                break;
            default:
                processed = false;
                break;
            }
            updateFilters();
            return processed;
        }
    });
    MenuInflater inflater = popup.getMenuInflater();
    Menu menu = popup.getMenu();
    inflater.inflate(R.menu.menu_scan_filters_name, menu);
    final boolean isFilterNameExact = mPeripheralList.isFilterNameExact();
    menu.findItem(isFilterNameExact ? R.id.scanfilter_name_exact : R.id.scanfilter_name_contains)
            .setChecked(true);
    final boolean isFilterNameCaseInsensitive = mPeripheralList.isFilterNameCaseInsensitive();
    menu.findItem(
            isFilterNameCaseInsensitive ? R.id.scanfilter_name_insensitive : R.id.scanfilter_name_sensitive)
            .setChecked(true);
    popup.show();
}

From source file:ac.robinson.mediaphone.MediaPhoneActivity.java

protected void setupMenuNavigationButtons(MenuInflater inflater, Menu menu, String frameId, boolean edited) {
    inflater.inflate(R.menu.previous_frame, menu);
    inflater.inflate(R.menu.next_frame, menu);
    // we should have already got focus by the time this is called, so can try to disable invalid buttons
    if (frameId != null) {
        NavigationMode navigationAllowed = FrameItem.getNavigationAllowed(getContentResolver(), frameId);
        if (navigationAllowed == NavigationMode.PREVIOUS || navigationAllowed == NavigationMode.NONE) {
            menu.findItem(R.id.menu_next_frame).setEnabled(false);
        }//from w ww.  j  a va 2s  .c om
        if (navigationAllowed == NavigationMode.NEXT || navigationAllowed == NavigationMode.NONE) {
            menu.findItem(R.id.menu_previous_frame).setEnabled(false);
        }
    }
    inflater.inflate(R.menu.add_frame, menu);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        if (edited) {
            inflater.inflate(R.menu.finished_editing, menu);
        } else {
            inflater.inflate(R.menu.back_without_editing, menu);
        }
    }
}

From source file:at.ac.tuwien.caa.docscan.ui.CameraActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.actionbar_menu, menu);

    mFlashMenuItem = menu.findItem(R.id.flash_mode_item);

    // The flash menu item is not visible at the beginning ('weak' devices might have no flash)
    if (mFlashModes != null)
        mFlashMenuItem.setVisible(true);

    return true;/* ww w  . j  a va2s .co  m*/

}