• 第二阶段冲刺第五天


    import android.os.Bundle;
    import android.support.annotation.Nullable;
    import android.support.v4.app.Fragment;
    import android.support.v4.app.FragmentManager;
    import android.support.v4.app.FragmentPagerAdapter;
    
    import com.example.myapplication.Fragment.HistoryContentFragment;
    import com.example.myapplication.Fragment.HistoryFragment;
    
    import java.util.ArrayList;
    
    /**
     * @author:created By ZhangHao
     * 时间:2019/5/6 01
     * 邮箱:188660586@qq.com
     */
    public class historyFragmentAdapter extends FragmentPagerAdapter {
        private ArrayList<String>titles;
        public historyFragmentAdapter(FragmentManager fm) {
            super(fm);
            this.titles=new ArrayList<>();
        }
    
        /*
         **
         *数据列表
         **
        */
    
    
        public void setTitles(ArrayList<String> titles) {
            this.titles.clear();
            this.titles.addAll(titles);
            notifyDataSetChanged();
        }
    
    
        @Override
        public Fragment getItem(int i) {
            HistoryContentFragment historyContentFragment = new HistoryContentFragment();
            Bundle bundle = new Bundle();
            bundle.putString("titles",titles.get(i));
            historyContentFragment.setArguments(bundle);
            return historyContentFragment;
        }
    
        @Override
        public int getCount() {
            return titles.size();
        }
    
    
        @Override
        public CharSequence getPageTitle(int position) {
    
            String plateName= titles.get(position);
            if(plateName==null){
                plateName="";
            }else if(plateName.length()>15){
                plateName=plateName.substring(0,15)+"...";
            }
            return plateName;
        }
    }
  • 相关阅读:
    【c++】龟兔赛跑问题
    【2016.3.21】关于字符串的一点总结
    程序员面试宝典(第五版)里的错误
    团队作业_总结_RTCSD2017
    团队作业_一周二周_RTCSD2017
    第三次作业_RTCSD2017
    第二次作业_RTCSD
    分析Demo1闪灯例程里的main.c
    第一次作业_RTCSD2017
    约束与自由
  • 原文地址:https://www.cnblogs.com/zhang188660586/p/11061962.html
Copyright © 2020-2023  润新知