android.support.design.widget.BottomNavigationView.getChildAt()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中android.support.design.widget.BottomNavigationView.getChildAt()方法的一些代码示例,展示了BottomNavigationView.getChildAt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BottomNavigationView.getChildAt()方法的具体详情如下:
包路径:android.support.design.widget.BottomNavigationView
类名称:BottomNavigationView
方法名:getChildAt

BottomNavigationView.getChildAt介绍

暂无

代码示例

代码示例来源:origin: iMeiji/Toutiao

public static void disableShiftMode(BottomNavigationView view) {
    BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.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);
        //noinspection RestrictedApi
        item.setShiftingMode(false);
        // set once again checked value, so view will be updated
        //noinspection RestrictedApi
        item.setChecked(item.getItemData().isChecked());
      }
    } catch (NoSuchFieldException e) {
      Log.e("BNVHelper", "Unable to get shift mode field", e);
    } catch (IllegalAccessException e) {
      Log.e("BNVHelper", "Unable to change value of shift mode", e);
    }
  }
}

代码示例来源:origin: InnoFang/Android-Code-Demos

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;
  }
}

代码示例来源:origin: InnoFang/Android-Code-Demos

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();
  }
}

代码示例来源:origin: AbrahamCaiJin/BottomAndShapeDemo

@RequiresApi(api = Build.VERSION_CODES.KITKAT)
  @SuppressLint("RestrictedApi")
  public static void disableShiftMode(BottomNavigationView navigationView) {

    BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
    try {
      // 利用反射,改变 item 中 mShiftingMode 的值 ,从而改变 BottomNavigationView 默认的效果
      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();
    }
  }
}

代码示例来源:origin: brucevanfdm/BottomNavigationView

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();
    }
  }
}

代码示例来源:origin: xkzh/yduoduo

public static void disableShiftMode(BottomNavigationView view) {
    //获取子View BottomNavigationMenuView的对象
    BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);
    try {
      //设置私有成员变量mShiftingMode可以修改
      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);
        //去除shift效果
        item.setShiftingMode(false);
        item.setChecked(item.getItemData().isChecked());
      }
    } catch (NoSuchFieldException e) {
    } catch (IllegalAccessException e) {
    }
  }
}

代码示例来源:origin: AbrahamCaiJin/BottomAndShapeDemo

BottomNavigationMenuView menuView = (BottomNavigationMenuView) bottomNavigationView.getChildAt(0);

代码示例来源:origin: JustinRoom/JSCKit

View child = navigation.getChildAt(i);
if (child instanceof BottomNavigationMenuView) {
  menuView = (BottomNavigationMenuView) child;

相关文章