Java Code Examples for android.support.v7.view.menu.MenuBuilder#getItem()

The following examples show how to use android.support.v7.view.menu.MenuBuilder#getItem() . 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: 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 3
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);
}