Code example for FrameLayout

Methods: setEnabledsetVisibilityaddViewgetChildCountremoveAllViews

0
 
    public void setEnabled(boolean enabled) {
        super.setEnabled(enabled);
        mImageButton.setEnabled(enabled);
        mTextButton.setEnabled(enabled);
        mCustomView.setEnabled(enabled);
    } 
 
    public void setDivider(ImageView divider) {
        mDivider = new WeakReference<ImageView>(divider);
    } 
 
    public void setVisible(boolean visible) {
        final int visibility = visible ? View.VISIBLE : View.GONE;
        if ((mDivider != null) && (mDivider.get() != null)) {
            mDivider.get().setVisibility(visibility);
        } 
        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