• 第二阶段冲刺4


    package com.example.shazidouhuiapp.activity;

     
    import android.os.Bundle;
    import android.widget.TextView;
     
    import androidx.annotation.Nullable;
    import androidx.appcompat.app.AppCompatActivity;
    import androidx.fragment.app.Fragment;
    import androidx.viewpager.widget.ViewPager;
     
    import com.ashokvarma.bottomnavigation.BottomNavigationBar;
    import com.ashokvarma.bottomnavigation.BottomNavigationItem;
     
    import com.example.shazidouhuiapp.Adapter.setAdapter;
    import com.example.shazidouhuiapp.R;
    import com.example.shazidouhuiapp.fragment.FragmentMine;
    import com.example.shazidouhuiapp.fragment.FragmentReadOver;
    import com.example.shazidouhuiapp.fragment.FragmentUnfinished;
     
    import java.util.ArrayList;
    import java.util.List;
     
     
    public class studentinterface extends AppCompatActivity implements BottomNavigationBar.OnTabSelectedListener, ViewPager.OnPageChangeListener {
        private ViewPager viewPager;
        private BottomNavigationBar bottomNavigationBar;
        private List<Fragment> fragmentList;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            viewPager=findViewById(R.id.viewpager);
            bottomNavigationBar=findViewById(R.id.bottom);
            initView();
     
        }
     
        private void initView() {
            initViewPager();
            initBottom();
     
        }
     
        private void initBottom() {
            bottomNavigationBar.setTabSelectedListener(this);
            bottomNavigationBar.clearAll();
            bottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED);
            bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_DEFAULT);
            bottomNavigationBar.setBarBackgroundColor(R.color.white).setActiveColor(R.color.colorbasel)
                    .setInActiveColor(R.color.black);
            bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.homepage_fill,"未完成作业").setInactiveIconResource(R.drawable.homepage))
                    .addItem(new BottomNavigationItem(R.drawable.mobilephone_fill,"已批改作业").setInactiveIconResource(R.drawable.mobilephone))
                    .addItem(new BottomNavigationItem(R.drawable.mine_fill,"我的").setInactiveIconResource(R.drawable.mine))
                    .setFirstSelectedPosition(0)
                    .initialise();
     
        }
     
        private void initViewPager() {
     
            viewPager.setOffscreenPageLimit(3);
     
            //配置fragment
            fragmentList=new ArrayList<>();
            //三个底部导航栏的实例化
            fragmentList.add(new FragmentUnfinished());
            fragmentList.add(new FragmentReadOver());
            fragmentList.add(new FragmentMine());
     
            viewPager.setAdapter(new setAdapter(getSupportFragmentManager(),fragmentList));
            viewPager.addOnPageChangeListener(this);
            viewPager.setCurrentItem(0);
        }
     
     
        @Override
        public void onTabSelected(int position) {
     
        }
     
        @Override
        public void onTabUnselected(int position) {
     
        }
     
        @Override
        public void onTabReselected(int position) {
            viewPager.setCurrentItem(position);
        }
     
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
     
        }
     
        @Override
        public void onPageSelected(int position) {
            bottomNavigationBar.selectTab(position);
        }
     
        @Override
        public void onPageScrollStateChanged(int state) {
     
        }
    }
  • 相关阅读:
    js 的一些兼容性写法
    浏览器 Event对象 及 属性 的兼容处理
    js 三元表达式 复杂写法
    Angular.js中使用$watch监听模型变化
    Android学习之——ViewPager及应用引导页的开发
    Android开发中常用的库总结(持续更新)
    Android学习之——GridView
    Android开发工具——Android studio1.0正式版使用技巧
    Android学习之——ListView下拉刷新
    Android学习之——ListView
  • 原文地址:https://www.cnblogs.com/wwbzuiku/p/13090375.html
Copyright © 2020-2023  润新知