Android PopupMenu - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android PopupMenu class.

This code example shows how to use the following methods: getMenu, getMenuInflater
	} 
	 
	public void inflate(int menuId) {
		// done without using the PopupMenu.inflate() method, which isn't available on Honeycomb. 
		// this method works on both Honeycomb and Ice Cream Sandwich. 
		MenuInflater inflater = menu.getMenuInflater();
		Menu baseMenu = menu.getMenu();
		inflater.inflate(menuId, baseMenu);
	} 
	 
	public void show() { 
		menu.show();
	} 
	 
	static { 
		try { 
			Class.forName("android.widget.PopupMenu");
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getMenu, getMenuInflater, setOnMenuItemClickListener
This code example shows how to use the following methods: setOnMenuItemClickListener
        }); 
    } 
 
    public void setOnDropdownMenuItemClickListener(OnMenuItemClickListener listener) {
        if (mPopupMenu != null) {
            mPopupMenu.setOnMenuItemClickListener(listener);
        } 
    } 
 
    public MenuItem findItem(int id) {
        return mMenu.findItem(id);
    } 
 
    public void setTitle(CharSequence title) {
        mButton.setText(title);
    } 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getMenu, getMenuInflater, setOnMenuItemClickListener, show
 */ 
public class PopupMenuHelperHoneycomb extends PopupMenuHelperBase { 
 
    @Override 
    public void showMenu(final Activity activity, View anchor, int menuResource) {
        PopupMenu popup = new PopupMenu(activity, anchor);
 
        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            @Override 
            public boolean onMenuItemClick(MenuItem menuItem) {
                return activity.onOptionsItemSelected(menuItem);
            } 
        }); 
        MenuInflater inflater = popup.getMenuInflater();
        inflater.inflate(menuResource, popup.getMenu());
 
        activity.onPrepareOptionsMenu(popup.getMenu());
        popup.show();
    } 
 

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getMenu, getMenuInflater, setOnMenuItemClickListener, show
 */ 
public class PopupMenuHelperHoneycomb extends PopupMenuHelperBase { 
 
    @Override 
    public void showMenu(final Activity activity, View anchor, int menuResource) {
        PopupMenu popup = new PopupMenu(activity, anchor);
 
        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            @Override 
            public boolean onMenuItemClick(MenuItem menuItem) {
                return activity.onOptionsItemSelected(menuItem);
            } 
        }); 
        MenuInflater inflater = popup.getMenuInflater();
        inflater.inflate(menuResource, popup.getMenu());
 
        activity.onPrepareOptionsMenu(popup.getMenu());
        popup.show();
    } 
 

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android PopupMenu Questions & Answers:

Other Android PopupMenu Examples

1:	public void showMenu(View v) {
2:	    PopupMenu popup = new PopupMenu(this, v);
3:	
4:	    // This activity implements OnMenuItemClickListener
-
1:	public void showMenu(View v) {
2:	    PopupMenu popup = new PopupMenu(this, v);
3:	
4:	    // This activity implements OnMenuItemClickListener

Read More

1:	public void showPopup(View v) {
2:	    PopupMenu popup = new PopupMenu(this, v);
3:	    MenuInflater inflater = popup.getMenuInflater();
4:	    inflater.inflate(R.menu.actions, popup.getMenu());
-
1:	public void showPopup(View v) {
2:	    PopupMenu popup = new PopupMenu(this, v);
3:	    MenuInflater inflater = popup.getMenuInflater();
4:	    inflater.inflate(R.menu.actions, popup.getMenu());

Read More

See Code Examples for Android PopupMenu Methods: