当前位置: 首页>>代码示例>>Java>>正文


Java IDrawerItem.generateView方法代码示例

本文整理汇总了Java中com.mikepenz.materialdrawer.model.interfaces.IDrawerItem.generateView方法的典型用法代码示例。如果您正苦于以下问题:Java IDrawerItem.generateView方法的具体用法?Java IDrawerItem.generateView怎么用?Java IDrawerItem.generateView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mikepenz.materialdrawer.model.interfaces.IDrawerItem的用法示例。


在下文中一共展示了IDrawerItem.generateView方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fillStickyDrawerItemFooter

import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入方法依赖的package包/类
/**
 * helper method to fill the sticky footer with it's elements
 *
 * @param drawer
 * @param container
 * @param onClickListener
 */
public static void fillStickyDrawerItemFooter(DrawerBuilder drawer, ViewGroup container, View.OnClickListener onClickListener) {
    //add all drawer items
    for (IDrawerItem drawerItem : drawer.mStickyDrawerItems) {
        View view = drawerItem.generateView(container.getContext(), container);
        view.setTag(drawerItem);

        if (drawerItem.isEnabled()) {
            //UIUtils.setBackground(view, UIUtils.getSelectableBackground(container.getContext(), selected_color, true));
            view.setOnClickListener(onClickListener);
        }

        container.addView(view);

        //for android API 17 --> Padding not applied via xml
        DrawerUIUtils.setDrawerVerticalPadding(view);
    }
    //and really. don't ask about this. it won't set the padding if i don't set the padding for the container
    container.setPadding(0, 0, 0, 0);
}
 
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:27,代码来源:DrawerUtils.java

示例2: build

import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入方法依赖的package包/类
public View build() {
    //create the container view
    LinearLayout linearLayout = new LinearLayout(mContext);
    linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    //create the divider
    if (mDivider) {
        LinearLayout divider = new LinearLayout(mContext);
        divider.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        divider.setMinimumHeight((int) UIUtils.convertDpToPixel(1, mContext));
        divider.setOrientation(LinearLayout.VERTICAL);
        divider.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(mContext, R.attr.material_drawer_divider, R.color.material_drawer_divider));
        linearLayout.addView(divider);
    }

    //add all drawer items
    for (IDrawerItem drawerItem : mDrawerItems) {
        View view = drawerItem.generateView(mContext);
        view.setTag(drawerItem);

        if (drawerItem.isEnabled()) {
            view.setBackgroundResource(UIUtils.getSelectableBackgroundRes(mContext));
            view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnDrawerItemClickListener != null) {
                        mOnDrawerItemClickListener.onItemClick(v, (IDrawerItem) v.getTag());
                    }
                }
            });
        }

        linearLayout.addView(view);
    }

    return linearLayout;
}
 
开发者ID:LeMinhAn,项目名称:MaterialDrawer,代码行数:39,代码来源:DrawerItemViewHelper.java

示例3: build

import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入方法依赖的package包/类
public View build() {
    //create the container view
    LinearLayout linearLayout = new LinearLayout(mContext);
    linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    //create the divider
    if (mDivider) {
        LinearLayout divider = new LinearLayout(mContext);
        divider.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        divider.setMinimumHeight((int) UIUtils.convertDpToPixel(1, mContext));
        divider.setOrientation(LinearLayout.VERTICAL);
        divider.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(mContext, R.attr.material_drawer_divider, R.color.material_drawer_divider));
        linearLayout.addView(divider);
    }

    //add all drawer items
    for (IDrawerItem drawerItem : mDrawerItems) {
        View view = drawerItem.generateView(mContext);
        view.setTag(drawerItem);

        if (drawerItem.isEnabled()) {
            view.setBackgroundResource(DrawerUIUtils.getSelectableBackground(mContext));
            view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnDrawerItemClickListener != null) {
                        mOnDrawerItemClickListener.onItemClick(v, (IDrawerItem) v.getTag());
                    }
                }
            });
        }

        linearLayout.addView(view);
    }

    return linearLayout;
}
 
开发者ID:FreedomZZQ,项目名称:YouJoin-Android,代码行数:39,代码来源:DrawerItemViewHelper.java

示例4: fillStickyDrawerItemFooter

import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; //导入方法依赖的package包/类
/**
 * helper method to fill the sticky footer with it's elements
 *
 * @param drawer
 * @param container
 * @param onClickListener
 */
public static void fillStickyDrawerItemFooter(DrawerBuilder drawer, ViewGroup container, View.OnClickListener onClickListener) {
    //add all drawer items
    for (IDrawerItem drawerItem : drawer.mStickyDrawerItems) {
        //get the selected_color
        int selected_color = UIUtils.getThemeColorFromAttrOrRes(container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected);
        if (drawerItem instanceof PrimaryDrawerItem) {
            selected_color = ColorHolder.color(((PrimaryDrawerItem) drawerItem).getSelectedColor(), container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected);
        } else if (drawerItem instanceof SecondaryDrawerItem) {
            selected_color = ColorHolder.color(((SecondaryDrawerItem) drawerItem).getSelectedColor(), container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected);
        }

        View view = drawerItem.generateView(container.getContext(), container);
        view.setTag(drawerItem);

        if (drawerItem.isEnabled()) {
            UIUtils.setBackground(view, DrawerUIUtils.getSelectableBackground(container.getContext(), selected_color));
            view.setOnClickListener(onClickListener);
        }

        container.addView(view);

        //for android API 17 --> Padding not applied via xml
        DrawerUIUtils.setDrawerVerticalPadding(view);
    }
    //and really. don't ask about this. it won't set the padding if i don't set the padding for the container
    container.setPadding(0, 0, 0, 0);
}
 
开发者ID:FreedomZZQ,项目名称:YouJoin-Android,代码行数:35,代码来源:DrawerUtils.java


注:本文中的com.mikepenz.materialdrawer.model.interfaces.IDrawerItem.generateView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。