Example usage for android.view MenuInflater MenuInflater

List of usage examples for android.view MenuInflater MenuInflater

Introduction

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

Prototype

public MenuInflater(Context context) 

Source Link

Document

Constructs a menu inflater.

Usage

From source file:ie.tcd.scss.dsg.particpatory.SampleListFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Menu menu = newMenuInstance(getActivity());

    if (menu != null) {
        new MenuInflater(getActivity()).inflate(R.menu.sliding_menu, menu);
        MenuListAdapter adapter = new MenuListAdapter(getActivity());
        for (int i = 0; i < menu.size(); i++) {
            MenuItem item = menu.getItem(i);
            adapter.add(new SampleItem(item.getTitle().toString(), item.getIcon()));
        }/*w  w w . j a  va2s.  co  m*/

        setListAdapter(adapter);

    } else {
        TextView emptyText = new TextView(getActivity());
        emptyText.setText("No Menu");
        getListView().setEmptyView(emptyText);
    }
    ListView listView = new ListView(getActivity());
    listView.setId(android.R.id.list);
    return listView;
}

From source file:com.android.screenspeak.contextmenu.ListMenuPreparer.java

public void prepareMenu(ListMenu menu, int menuId) {
    if (menuId == R.menu.global_context_menu) {
        new MenuInflater(mContext).inflate(R.menu.global_context_menu, menu);
        menu.removeItem(R.id.quick_navigation);
        menu.setTitle(mContext.getString(R.string.global_context_menu_title));
    } else if (menuId == R.menu.local_context_menu) {
        ScreenSpeakService service = ScreenSpeakService.getInstance();
        if (service == null) {
            return;
        }/* w w  w.ja  va 2 s.co  m*/

        final AccessibilityNodeInfoCompat currentNode = service.getCursorController().getCursor();
        if (currentNode == null) {
            return;
        }

        NodeMenuRuleProcessor menuRuleProcessor = new NodeMenuRuleProcessor(service);
        menuRuleProcessor.prepareMenuForNode(menu, currentNode);
        currentNode.recycle();
        menu.setTitle(mContext.getString(R.string.local_context_menu_title));
    }
}

From source file:com.commonsware.android.feedfrags.AbstractFeedsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    new MenuInflater(this).inflate(R.menu.feeds_options, menu);

    return (super.onCreateOptionsMenu(menu));
}

From source file:com.android.talkback.contextmenu.ListMenuPreparer.java

public void prepareMenu(ListMenu menu, int menuId) {
    TalkBackService service = TalkBackService.getInstance();
    if (service == null) {
        return;/*from  w  ww  .  j  a v  a 2 s  .  co  m*/
    }

    if (menuId == R.menu.global_context_menu) {
        new MenuInflater(mContext).inflate(R.menu.global_context_menu, menu);
        menu.removeItem(R.id.quick_navigation);

        GlobalMenuProcessor globalMenuProcessor = new GlobalMenuProcessor(service);
        globalMenuProcessor.prepareMenu(menu);
        menu.setTitle(mContext.getString(R.string.global_context_menu_title));
    } else if (menuId == R.menu.local_context_menu) {
        final AccessibilityNodeInfoCompat currentNode = service.getCursorController().getCursorOrInputCursor();
        if (currentNode == null) {
            return;
        }

        NodeMenuRuleProcessor menuRuleProcessor = new NodeMenuRuleProcessor(service);
        menuRuleProcessor.prepareMenuForNode(menu, currentNode);
        currentNode.recycle();
        menu.setTitle(mContext.getString(R.string.local_context_menu_title));
    } else if (menuId == R.id.custom_action_menu) {
        final AccessibilityNodeInfoCompat currentNode = service.getCursorController().getCursorOrInputCursor();
        if (currentNode == null) {
            return;
        }

        NodeMenuRuleProcessor menuRuleProcessor = new NodeMenuRuleProcessor(service);
        menuRuleProcessor.prepareCustomActionMenuForNode(menu, currentNode);
        currentNode.recycle();
        menu.setTitle(mContext.getString(R.string.title_custom_action));
    }
}

From source file:com.commonsware.android.feedfrags.FeedsNavActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    new MenuInflater(this).inflate(R.menu.feeds_nav_options, menu);

    return (super.onCreateOptionsMenu(menu));
}

From source file:com.koushikdutta.superuser.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater mi = new MenuInflater(this);
    mi.inflate(R.menu.app, menu);// w  w w  .ja  va 2s . c  om
    MenuItem about = menu.findItem(R.id.about);
    about.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            getSupportFragmentManager().beginTransaction().addToBackStack(getString(R.string.about))
                    .replace(getListContainerId(), new AboutFragment(), "content").commit();
            return true;
        }
    });

    MenuItem settings = menu.findItem(R.id.settings);
    settings.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(final MenuItem item) {
            getSupportFragmentManager().beginTransaction().addToBackStack(getString(R.string.settings))
                    .replace(getListContainerId(), new SettingsFragment(), "content").commit();
            return true;
        }
    });
    return super.onCreateOptionsMenu(menu);
}

From source file:com.android.screenspeak.contextmenu.ScreenSpeakRadialMenuClient.java

public ScreenSpeakRadialMenuClient(ScreenSpeakService service) {
    mService = service;/*from w  w  w . ja v a  2  s  .  com*/
    mMenuInflater = new MenuInflater(mService);
    mMenuRuleProcessor = new NodeMenuRuleProcessor(mService);
    mMenuClickProcessor = new ContextMenuItemClickProcessor(mService);
}

From source file:com.commonsware.android.feedfrags.FeedsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        new MenuInflater(this).inflate(R.menu.feeds_hc_options, menu);
    }// w  w  w .j  a va  2s .  c o m

    return (super.onCreateOptionsMenu(menu));
}

From source file:com.google.android.marvin.mytalkback.TalkBackRadialMenuClient.java

public TalkBackRadialMenuClient(TalkBackService service) {
    mService = service;/*from w ww .  jav a  2s .co  m*/
    mMenuInflater = new MenuInflater(mService);

    if (Build.VERSION.SDK_INT >= NodeMenuRuleProcessor.MIN_API_LEVEL) {
        mMenuRuleProcessor = new NodeMenuRuleProcessor(mService);
    } else {
        mMenuRuleProcessor = null;
    }
}

From source file:com.android.talkback.contextmenu.TalkBackRadialMenuClient.java

public TalkBackRadialMenuClient(TalkBackService service) {
    mService = service;//from  ww  w  .ja va 2  s  . com
    mMenuInflater = new MenuInflater(mService);
    mMenuRuleProcessor = new NodeMenuRuleProcessor(mService);
    mGlobalMenuProcessor = new GlobalMenuProcessor(mService);
    mMenuClickProcessor = new ContextMenuItemClickProcessor(mService);
}