MenuItem setCheckable - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MenuItem setCheckable method.

This code example shows how to use the following methods:setCheckable, setChecked, setVisible
        } 
    }; 
     
    private void addStyleMenu(Menu menu, int style, char shortCut) {
        MenuItem item = menu.add(0, style, 0, (style == Typeface.BOLD) ? "Bold" : "Italic");
        item.setCheckable(true);
        item.setOnMenuItemClickListener(mStyleClickListener);
        item.setChecked((mFontStyle & style) != 0);
 
        item.setVisible(canSupportStyle(sTypeface[mFontIndex], style));
        if (shortCut != 0) {
            item.setAlphabeticShortcut(shortCut);
        } 
    } 
     
    private MenuItem.OnMenuItemClickListener mFlagClickListener = new MenuItem.OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) { 
            int mask = item.getItemId(); 
            mColumn1.setPaintFlags(mColumn1.getPaintFlags() ^ mask); 
            mColumn2.setPaintFlags(mColumn2.getPaintFlags() ^ mask); 
6
CodeRank
This code example shows how to use the following methods:setCheckable
    public boolean onCreateOptionsMenu(Menu menu)
    { 
        super.onCreateOptionsMenu(menu);
        mProfilingItem = menu.add(0, 0, 0, "Profiling Mode")
        .setOnMenuItemClickListener(mProfilingCallback);
        mProfilingItem.setCheckable(true);
        return true; 
    } 
 
    @Override 
    public boolean onPrepareOptionsMenu(Menu menu)
    { 
        super.onPrepareOptionsMenu(menu);
        mProfilingItem.setChecked(mProfilingMode);
        return true; 
    } 
 
    @Override 
    protected void onSaveInstanceState(Bundle outState)
    { 
4
CodeRank
This code example shows how to use the following methods:setCheckable
		return menuItem.setAlphabeticShortcut(alphaChar);
	} 
 
	@Override 
	public MenuItem setCheckable(boolean checkable) {
		return menuItem.setCheckable(checkable);
	} 
 
	@Override 
	public MenuItem setChecked(boolean checked) {
		return menuItem.setChecked(checked);
	} 
 
	@Override 
	public MenuItem setEnabled(boolean enabled) {
		if (getActionView() != null) { 
			getActionView().setEnabled(enabled);
		} 
		return menuItem.setEnabled(enabled);
	} 
5
CodeRank
setCheckable Method Overview
Control whether this item can display a check mark.
See Code Examples for other Android MenuItem Methods: