zoukankan      html  css  js  c++  java
  • 第二阶段冲刺(六)

    昨天学习了导航栏和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(); 
    }
  • 相关阅读:
    不写helloworld总觉得哪里似乎不对之javascript
    SQl中drop与truncate的区别
    对MarshalByRefObject的讲解(转自DuDu)
    “模态子窗体关闭后,父窗体也关闭”解决方案
    ENVI5.0 32位工具栏图标不显示解决办法
    HTML5的基础写法
    查询远程服务器数据
    javascript变量、作用域和内存问题
    javascript基本概念
    让应用程序具体相应权限
  • 原文地址:https://www.cnblogs.com/lq13035130506/p/11003310.html
Copyright © 2011-2022 走看看