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


Java BottomNavigationItemView.setChecked方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: addUnreadBadges

import android.support.design.internal.BottomNavigationItemView; //导入方法依赖的package包/类
/**
 * Add the unread messages badges.
 */
@SuppressLint("RestrictedApi")
private void addUnreadBadges() {
    final float scale = getResources().getDisplayMetrics().density;
    int badgeOffsetX = (int) (18 * scale + 0.5f);
    int badgeOffsetY = (int) (7 * scale + 0.5f);

    removeMenuShiftMode();

    int largeTextHeight = getResources().getDimensionPixelSize(android.support.design.R.dimen.design_bottom_navigation_active_text_size);

    for (int menuIndex = 0; menuIndex < mBottomNavigationView.getMenu().size(); menuIndex++) {
        try {
            int itemId = mBottomNavigationView.getMenu().getItem(menuIndex).getItemId();
            BottomNavigationItemView navigationItemView = mBottomNavigationView.findViewById(itemId);


            navigationItemView.setShiftingMode(false);

            Field marginField = navigationItemView.getClass().getDeclaredField("mDefaultMargin");
            marginField.setAccessible(true);
            marginField.setInt(navigationItemView, marginField.getInt(navigationItemView) + (largeTextHeight / 2));
            marginField.setAccessible(false);

            Field shiftAmountField = navigationItemView.getClass().getDeclaredField("mShiftAmount");
            shiftAmountField.setAccessible(true);
            shiftAmountField.setInt(navigationItemView, 0);
            shiftAmountField.setAccessible(false);

            navigationItemView.setChecked(navigationItemView.getItemData().isChecked());

            View iconView = navigationItemView.findViewById(R.id.icon);

            if (iconView.getParent() instanceof FrameLayout) {
                UnreadCounterBadgeView badgeView = new UnreadCounterBadgeView(iconView.getContext());

                // compute the new position
                FrameLayout.LayoutParams iconViewLayoutParams = (FrameLayout.LayoutParams) iconView.getLayoutParams();
                FrameLayout.LayoutParams badgeLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
                badgeLayoutParams.setMargins(iconViewLayoutParams.leftMargin + badgeOffsetX, iconViewLayoutParams.topMargin - badgeOffsetY, iconViewLayoutParams.rightMargin, iconViewLayoutParams.bottomMargin);
                badgeLayoutParams.gravity = iconViewLayoutParams.gravity;

                ((FrameLayout) iconView.getParent()).addView(badgeView, badgeLayoutParams);
                mBadgeViewByIndex.put(itemId, badgeView);
            }
        } catch (Exception e) {
            Log.e(LOG_TAG, "## addUnreadBadges failed " + e.getMessage());
        }
    }

    refreshUnreadBadges();
}
 
开发者ID:vector-im,项目名称:riot-android,代码行数:55,代码来源:VectorHomeActivity.java


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