• 第二阶段冲刺(六)


    昨天学习了导航栏和Tab的转换

    遇到的困难是:发现在部分Android手机上底部会有导航栏,在写xml布局的时候,该导航栏会遮挡住部分布局页面。

    今天准备继续学习底部导航栏

    mBottomNavigationBar = (BottomNavigationBar) view.findViewById(R.id.bottom_navigation_bar);
    mBottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC);
    mBottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED);
    mBottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.home_fill, getString(R.string.item_home)).setInactiveIconResource(R.drawable.home).setActiveColorResource(R.color.colorPrimary).setInActiveColorResource(R.color.black_1))       
     .addItem(new BottomNavigationItem(R.drawable.location_fill, getString(R.string.item_location)).setInactiveIconResource(R.drawable.location).setActiveColorResource(R.color.colorPrimary).setInActiveColorResource(R.color.black_1))       
     .addItem(new BottomNavigationItem(R.drawable.like_fill, getString(R.string.item_like)).setInactiveIconResource(R.drawable.like).setActiveColorResource(R.color.colorPrimary).setInActiveColorResource(R.color.black_1))       
     .addItem(new BottomNavigationItem(R.drawable.person_fill, getString(R.string.item_person)).setInactiveIconResource(R.drawable.person).setActiveColorResource(R.color.colorPrimary).setInActiveColorResource(R.color.black_1))       
     .setFirstSelectedPosition(0)        
    .initialise();
    mBottomNavigationBar.setTabSelectedListener(this);
    
    @Override 
    public void onTabSelected(int position) { FragmentTransaction beginTransaction = getFragmentManager().beginTransaction(); 
    switch (position) { 
    case 0:
     if (mHomeFragment == null) {
     mHomeFragment = HomeFragment.newInstance(getString(R.string.item_home));
     } 
    beginTransaction.replace(R.id.sub_content, mHomeFragment);
     break; 
    case 1: if (mLocationFragment == null) {
     mLocationFragment = LocationFragment.newInstance(getString(R.string.item_location)); 
    } 
    beginTransaction.replace(R.id.sub_content, mLocationFragment); 
    break; 
    case 2: 
    if (mLikeFragment == null) { 
    mLikeFragment = LikeFragment.newInstance(getString(R.string.item_like)); } 
    beginTransaction.replace(R.id.sub_content, mLikeFragment); 
    break;
    case 3: if (mPersonFragment == null) { 
    mPersonFragment = PersonFragment.newInstance(getString(R.string.item_person)); 
    } 
    beginTransaction.replace(R.id.sub_content, mPersonFragment); 
    } 
    break;
    beginTransaction.commit(); 
    }
  • 相关阅读:
    JS 随机整数
    微信小程序 功能函数 支付接口
    JS 正则表达式
    JS 日期 自动补齐 “2017-11-22 14:43”
    schema get_ddl
    StringBuffer 清空
    java中split任意数量的空白字符
    美国法官工资
    纪检委,检察院的工资
    国家司法机构
  • 原文地址:https://www.cnblogs.com/lq13035130506/p/11003310.html
Copyright © 2020-2023  润新知