Code example for FrameLayout

Methods: addViewgetChildCountremoveAllViews, setVisibility

0
setVisibility(visibility);
    } 
 
    public void reloadDisplay() { 
        final boolean hasCustomView = mCustomView.getChildCount() > 0;
        final boolean hasText = mMenuItem.showsActionItemText() && !"".equals(mTextButton.getText());
 
        if (hasCustomView) {
            mCustomView.setVisibility(View.VISIBLE);
            mImageButton.setVisibility(View.GONE);
            mTextButton.setVisibility(View.GONE);
        } else { 
            mCustomView.setVisibility(View.GONE);
            mImageButton.setVisibility(View.VISIBLE);
            mTextButton.setVisibility(hasText ? View.VISIBLE : View.GONE);
        } 
    } 
 
    public void setIcon(Drawable icon) {
        mImageButton.setImageDrawable(icon);
    } 
 
    public void setTitle(CharSequence title) {
        mTextButton.setText(title);
        reloadDisplay(); 
    } 
 
    @Override 
    public void initialize(MenuItemImpl itemData, int menuType) {
        mMenuItem = itemData;
        setId(itemData.getItemId());
        setIcon(itemData.getIcon());
        setTitle(itemData.getTitle());
        setEnabled(itemData.isEnabled());
        setActionView(itemData.getActionView());
        setVisible(itemData.isVisible());
    } 
 
    @Override 
    public MenuItemImpl getItemData() { 
        return mMenuItem;
    } 
 
    @Override 
    public void setCheckable(boolean checkable) {
        // No-op 
    } 
 
    @Override 
    public void setChecked(boolean checked) {
        // No-op 
    } 
 
    @Override 
    public void setShortcut(boolean showShortcut, char shortcutKey) {
        // No-op 
    } 
 
    @Override 
    public void setActionView(View actionView) {
        mCustomView.removeAllViews();
        if (actionView != null) {
            mCustomView.addView(actionView);
        } 
        reloadDisplay(); 
    } 
 
    @Override