zoukankan      html  css  js  c++  java
  • 第二阶段冲刺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) {
     
        }
    }
  • 相关阅读:
    陪伴
    休假
    I'm back
    Mysql程序
    Mysql 行转列
    Struts2 设置--Myelipse
    struts2 严重: Error filterStart 原因
    廉价药
    在linux下用tomcat部署java web项目的过程与注意事项
    创建表格式
  • 原文地址:https://www.cnblogs.com/wwbzuiku/p/13090375.html
Copyright © 2011-2022 走看看