android.support.v7.view.SupportMenuInflater Java Examples

The following examples show how to use android.support.v7.view.SupportMenuInflater. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BottomDialog.java    From imsdk-android with MIT License 5 votes vote down vote up
public void inflateMenu(int menu) {
    MenuInflater menuInflater = new SupportMenuInflater(getContext());
    MenuBuilder menuBuilder = new MenuBuilder(getContext());
    menuInflater.inflate(menu, menuBuilder);
    List<Item> items = new ArrayList<>();
    for (int i = 0; i < menuBuilder.size(); i++) {
        MenuItem menuItem = menuBuilder.getItem(i);
        Item item = new Item();
        item.setId(menuItem.getItemId());
        item.setIcon(menuItem.getIcon());
        item.setTitle(menuItem.getTitle().toString());
        items.add(item);
    }
    addItems(items);
}
 
Example #2
Source File: NoFragment.java    From NoFragment with Apache License 2.0 5 votes vote down vote up
/**
 * Set Toolbar.
 *
 * @param toolbar {@link Toolbar}.
 */
public final void setToolbar(@NonNull Toolbar toolbar) {
    this.mToolbar = toolbar;
    onCreateOptionsMenu(mToolbar.getMenu(), new SupportMenuInflater(mActivity));
    mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return onOptionsItemSelected(item);
        }
    });
}
 
Example #3
Source File: CustomDialog.java    From YCDialog with Apache License 2.0 5 votes vote down vote up
@SuppressLint("RestrictedApi")
void inflateMenu(int menu, OnItemClickListener onItemClickListener) {
    MenuInflater menuInflater = new SupportMenuInflater(getContext());
    MenuBuilder menuBuilder = new MenuBuilder(getContext());
    menuInflater.inflate(menu, menuBuilder);
    List<CustomItem> items = new ArrayList<>();
    for (int i = 0; i < menuBuilder.size(); i++) {
        MenuItem menuItem = menuBuilder.getItem(i);
        items.add(new CustomItem(menuItem.getItemId(), menuItem.getTitle().toString(), menuItem.getIcon()));
    }
    addItems(items, onItemClickListener);
}
 
Example #4
Source File: BottomDialog.java    From BottomDialog with MIT License 5 votes vote down vote up
public void inflateMenu(int menu) {
    MenuInflater menuInflater = new SupportMenuInflater(getContext());
    MenuBuilder menuBuilder = new MenuBuilder(getContext());
    menuInflater.inflate(menu, menuBuilder);
    List<Item> items = new ArrayList<>();
    for (int i = 0; i < menuBuilder.size(); i++) {
        MenuItem menuItem = menuBuilder.getItem(i);
        Item item = new Item();
        item.setId(menuItem.getItemId());
        item.setIcon(menuItem.getIcon());
        item.setTitle(menuItem.getTitle().toString());
        items.add(item);
    }
    addItems(items);
}
 
Example #5
Source File: DrawerBuilder.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
/**
 * Inflates the DrawerItems from a menu.xml
 *
 * @param menuRes
 * @return
 */
public DrawerBuilder inflateMenu(@MenuRes int menuRes) {
    MenuInflater menuInflater = new SupportMenuInflater(mActivity);
    MenuBuilder mMenu = new MenuBuilder(mActivity);

    menuInflater.inflate(menuRes, mMenu);

    addMenuItems(mMenu, false);

    return this;
}
 
Example #6
Source File: MenuSheetView.java    From bottomsheet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Inflates a menu resource into the menu backing this sheet.
 *
 * @param menuRes Menu resource ID
 */
public void inflateMenu(@MenuRes int menuRes) {
    if (menuRes != -1) {
        SupportMenuInflater inflater = new SupportMenuInflater(getContext());
        inflater.inflate(menuRes, menu);
    }

    prepareMenuItems();
}
 
Example #7
Source File: ViewSource.java    From mvp-sample with Apache License 2.0 4 votes vote down vote up
@Override
MenuInflater getMenuInflater() {
    return new SupportMenuInflater(mActionBar != null ? mActionBar.getContext() : getContext());
}
 
Example #8
Source File: ActivitySource.java    From mvp-sample with Apache License 2.0 4 votes vote down vote up
@Override
MenuInflater getMenuInflater() {
    return new SupportMenuInflater(mActionBar != null ? mActionBar.getContext() : getContext());
}
 
Example #9
Source File: FloatingToolbar.java    From FloatingToolbar with Apache License 2.0 4 votes vote down vote up
/**
 * Set a menu from it's resource id.
 *
 * @param menuRes menu resource to be set
 */
public void setMenu(@MenuRes int menuRes) {
    mMenu = new MenuBuilder(getContext());
    new SupportMenuInflater(getContext()).inflate(menuRes, mMenu);
    setMenu(mMenu);
}
 
Example #10
Source File: ViewSource.java    From Album with Apache License 2.0 4 votes vote down vote up
@Override
MenuInflater getMenuInflater() {
    return new SupportMenuInflater(getContext());
}
 
Example #11
Source File: ActivitySource.java    From Album with Apache License 2.0 4 votes vote down vote up
@Override
MenuInflater getMenuInflater() {
    return new SupportMenuInflater(getContext());
}