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


Java BottomNavigationItemView类代码示例

本文整理汇总了Java中android.support.design.internal.BottomNavigationItemView的典型用法代码示例。如果您正苦于以下问题:Java BottomNavigationItemView类的具体用法?Java BottomNavigationItemView怎么用?Java BottomNavigationItemView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setBottomIconOriColor

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
private void setBottomIconOriColor(BottomNavigationView bottomView) {
    try {
        Field mMenuViewField = BottomNavigationView.class.getDeclaredField("mMenuView");
        mMenuViewField.setAccessible(true);
        BottomNavigationMenuView mMenuView = (BottomNavigationMenuView) mMenuViewField.get(bottomView);

        Field mButtonsField = BottomNavigationMenuView.class.getDeclaredField("mButtons");
        mButtonsField.setAccessible(true);
        BottomNavigationItemView[] mButtons = (BottomNavigationItemView[]) mButtonsField.get(mMenuView);

        Field mIconField = BottomNavigationItemView.class.getDeclaredField("mIcon");
        mIconField.setAccessible(true);

        for (BottomNavigationItemView item : mButtons) {
            ImageView mIcon = (ImageView) mIconField.get(item);
            mIcon.setImageTintList(null);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:iAcn,项目名称:MBEStyle,代码行数:23,代码来源:MainActivity.java

示例2: disableShiftMode

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
public static void disableShiftMode(BottomNavigationView navigationView) {
    BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);

    try {
        Field shiftMode = menuView.getClass().getDeclaredField("mShiftingMode");
        shiftMode.setAccessible(true);
        shiftMode.setBoolean(menuView, false);
        shiftMode.setAccessible(false);

        for (int i = 0; i < menuView.getChildCount(); i++) {
            BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
            itemView.setShiftingMode(false);
            itemView.setChecked(itemView.getItemData().isChecked());
        }

    } catch (NoSuchFieldException | IllegalAccessException e) {
        e.printStackTrace();
    }
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:20,代码来源:BottomNavigationViewHelper.java

示例3: centerMenuIcon

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
private void centerMenuIcon() {
    BottomNavigationMenuView menuView = getBottomMenuView();

    if (menuView != null) {
        for (int i = 0; i < menuView.getChildCount(); i++) {
            BottomNavigationItemView menuItemView = (BottomNavigationItemView) menuView.getChildAt(i);

            AppCompatImageView icon = (AppCompatImageView) menuItemView.getChildAt(0);

            FrameLayout.LayoutParams params = (LayoutParams) icon.getLayoutParams();
            params.gravity = Gravity.CENTER;

            menuItemView.setShiftingMode(true);
        }
    }
}
 
开发者ID:JonathandelaSen,项目名称:TheMovies,代码行数:17,代码来源:MyBottomNavigationView.java

示例4: enableItemShiftingMode

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
/**
 * enable the shifting mode for each item
 *
 * @param enable It will has a shift animation for item if true. Otherwise the item text always be shown.
 */
public void enableItemShiftingMode(boolean enable) {
    /*
    1. get field in this class
    private final BottomNavigationMenuView mMenuView;

    2. get field in this mMenuView
    private BottomNavigationItemView[] mButtons;

    3. change field mShiftingMode value in mButtons
    private boolean mShiftingMode = true;
     */
    // 1. get mMenuView
    BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
    // 2. get mButtons
    BottomNavigationItemView[] mButtons = getBottomNavigationItemViews();
    // 3. change field mShiftingMode value in mButtons
    for (BottomNavigationItemView button : mButtons) {
        setField(button.getClass(), button, "mShiftingMode", enable);
    }
    mMenuView.updateMenuView();
}
 
开发者ID:wheat7,项目名称:Cashew,代码行数:27,代码来源:BottomNavigationViewEx.java

示例5: getCurrentItem

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
/**
     * get the current checked item position
     *
     * @return index of item, start from 0.
     */
    public int getCurrentItem() {
        /*
        1. get field in this class
        private final BottomNavigationMenuView mMenuView;

        2. get field in mMenuView
        private BottomNavigationItemView[] mButtons;

        3. get menu and traverse it to get the checked one
         */

        // 1. get mMenuView
//        BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
        // 2. get mButtons
        BottomNavigationItemView[] mButtons = getBottomNavigationItemViews();
        // 3. get menu and traverse it to get the checked one
        Menu menu = getMenu();
        for (int i = 0; i < mButtons.length; i++) {
            if (menu.getItem(i).isChecked()) {
                return i;
            }
        }
        return 0;
    }
 
开发者ID:wheat7,项目名称:Cashew,代码行数:30,代码来源:BottomNavigationViewEx.java

示例6: disableShiftMode

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
public static void disableShiftMode(BottomNavigationView navigationView) {

        BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
        try {
            Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
            shiftingMode.setAccessible(true);
            shiftingMode.setBoolean(menuView, false);
            shiftingMode.setAccessible(false);

            for (int i = 0; i < menuView.getChildCount(); i++) {
                BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
                itemView.setShiftingMode(false);
                itemView.setChecked(itemView.getItemData().isChecked());
            }

        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:miguoer,项目名称:ApplicationCollention,代码行数:20,代码来源:BottomNavigationViewHelper.java

示例7: disableShiftMode

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
/**
 * 取消BottomNavigationView各item切换时的位移动效
 *
 * @param navigationView 底部导航栏视图
 */
public static void disableShiftMode(BottomNavigationView navigationView) {

    BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
    try {
        Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
        shiftingMode.setAccessible(true);
        shiftingMode.setBoolean(menuView, false);
        shiftingMode.setAccessible(false);

        for (int i = 0; i < menuView.getChildCount(); i++) {
            BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
            itemView.setShiftingMode(false);
            itemView.setChecked(itemView.getItemData().isChecked());
        }

    } catch (NoSuchFieldException | IllegalAccessException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Implementist,项目名称:iReading,代码行数:25,代码来源:CommonUtils.java

示例8: disableShiftingMode

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
private void disableShiftingMode() {
    BottomNavigationMenuView menuView = (BottomNavigationMenuView) getChildAt(0);
    try {
        Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
        shiftingMode.setAccessible(true);
        shiftingMode.setBoolean(menuView, false);
        shiftingMode.setAccessible(false);
        for (int i = 0; i < menuView.getChildCount(); i++) {
            BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
            item.setShiftingMode(false);
            // Set the checked value so that the view will be updated.
            item.setChecked(item.getItemData().isChecked());
        }
    } catch (NoSuchFieldException | IllegalAccessException e) {
        // Do nothing if reflection fails.
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:18,代码来源:BottomSheetContentController.java

示例9: getNavigationItemTitles

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
public static List<String> getNavigationItemTitles(BottomNavigationView navigationView) {
    List<String> list = new ArrayList<>();
    BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
    for (int i = 0; i < menuView.getChildCount(); i++) {
        BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
        list.add((String) itemView.getItemData().getTitle());
    }
    return list;
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:10,代码来源:BottomNavigationViewHelper.java

示例10: setCurrentItem

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
/**
     * set the current checked item
     *
     * @param item start from 0.
     */
    public void setCurrentItem(int item) {
        // check bounds
        if (item < 0 || item >= getMaxItemCount()) {
            throw new ArrayIndexOutOfBoundsException("item is out of bounds, we expected 0 - "
                    + (getMaxItemCount() - 1) + ". Actually " + item);
        }

        /*
        1. get field in this class
        private final BottomNavigationMenuView mMenuView;

        2. get field in mMenuView
        private BottomNavigationItemView[] mButtons;
        private final OnClickListener mOnClickListener;

        3. call mOnClickListener.onClick();
         */
        // 1. get mMenuView
        BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
        // 2. get mButtons
        BottomNavigationItemView[] mButtons = getBottomNavigationItemViews();
        // get mOnClickListener
        OnClickListener mOnClickListener = getField(mMenuView.getClass(), mMenuView, "mOnClickListener");

//        System.out.println("mMenuView:" + mMenuView + " mButtons:" + mButtons + " mOnClickListener" + mOnClickListener);
        // 3. call mOnClickListener.onClick();
        mOnClickListener.onClick(mButtons[item]);

    }
 
开发者ID:wheat7,项目名称:Cashew,代码行数:35,代码来源:BottomNavigationViewEx.java

示例11: getBottomNavigationItemViews

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
/**
 * get private mButtons in mMenuView
 *
 * @return
 */
public BottomNavigationItemView[] getBottomNavigationItemViews() {
    if (null != mButtons)
        return mButtons;
    /*
     * 1 private final BottomNavigationMenuView mMenuView;
     * 2 private BottomNavigationItemView[] mButtons;
     */
    BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
    mButtons = getField(mMenuView.getClass(), mMenuView, "mButtons");
    return mButtons;
}
 
开发者ID:wheat7,项目名称:Cashew,代码行数:17,代码来源:BottomNavigationViewEx.java

示例12: getIconAt

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
/**
 * get icon at position
 *
 * @param position
 * @return
 */
public ImageView getIconAt(int position) {
    /*
     * 1 private final BottomNavigationMenuView mMenuView;
     * 2 private BottomNavigationItemView[] mButtons;
     * 3 private ImageView mIcon;
     */
    BottomNavigationItemView mButtons = getBottomNavigationItemView(position);
    ImageView mIcon = getField(BottomNavigationItemView.class, mButtons, "mIcon");
    return mIcon;
}
 
开发者ID:wheat7,项目名称:Cashew,代码行数:17,代码来源:BottomNavigationViewEx.java

示例13: getSmallLabelAt

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
/**
 * get small label at position
 * Each item has tow label, one is large, another is small.
 *
 * @param position
 * @return
 */
public TextView getSmallLabelAt(int position) {
    /*
     * 1 private final BottomNavigationMenuView mMenuView;
     * 2 private BottomNavigationItemView[] mButtons;
     * 3 private final TextView mSmallLabel;
     */
    BottomNavigationItemView mButtons = getBottomNavigationItemView(position);
    TextView mSmallLabel = getField(BottomNavigationItemView.class, mButtons, "mSmallLabel");
    return mSmallLabel;
}
 
开发者ID:wheat7,项目名称:Cashew,代码行数:18,代码来源:BottomNavigationViewEx.java

示例14: getLargeLabelAt

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
/**
 * get large label at position
 * Each item has tow label, one is large, another is small.
 *
 * @param position
 * @return
 */
public TextView getLargeLabelAt(int position) {
    /*
     * 1 private final BottomNavigationMenuView mMenuView;
     * 2 private BottomNavigationItemView[] mButtons;
     * 3 private final TextView mLargeLabel;
     */
    BottomNavigationItemView mButtons = getBottomNavigationItemView(position);
    TextView mLargeLabel = getField(BottomNavigationItemView.class, mButtons, "mLargeLabel");
    return mLargeLabel;
}
 
开发者ID:wheat7,项目名称:Cashew,代码行数:18,代码来源:BottomNavigationViewEx.java

示例15: getItemCount

import android.support.design.internal.BottomNavigationItemView; //导入依赖的package包/类
/**
 * return item count
 *
 * @return
 */
public int getItemCount() {
    BottomNavigationItemView[] bottomNavigationItemViews = getBottomNavigationItemViews();
    if (null == bottomNavigationItemViews)
        return 0;
    return bottomNavigationItemViews.length;
}
 
开发者ID:wheat7,项目名称:Cashew,代码行数:12,代码来源:BottomNavigationViewEx.java


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