package com.example.mytictok.activity;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.androidkun.xtablayout.XTabLayout;
import com.example.mytictok.R;
import com.example.mytictok.adapter.CommPagerAdapter;
import com.example.mytictok.base.BaseActivity;
import com.example.mytictok.fragment.FansFragment;


import java.util.ArrayList;

import butterknife.BindView;


public class FocusActivity extends BaseActivity {
    @BindView(R.id.tablayout)
    XTabLayout tabLayout;
    @BindView(R.id.viewpager)
    ViewPager viewPager;
    private ArrayList<Fragment> fragments = new ArrayList<>();
    private CommPagerAdapter pagerAdapter;
    private String[] titles = new String[] {"关注 128", "粉丝 128", "推荐关注"};

    @Override
    protected int setLayoutId() {
        return R.layout.activity_focus;
    }

    @Override
    protected void init() {

        for (int i=0;i<titles.length;i++) {
            fragments.add(new FansFragment());
            tabLayout.addTab(tabLayout.newTab().setText(titles[i]));
        }

        pagerAdapter = new CommPagerAdapter(getSupportFragmentManager(), fragments, titles);
        viewPager.setAdapter(pagerAdapter);
        tabLayout.setupWithViewPager(viewPager);
    }
}

{'avg_line_length': 27.955555555555556, 'max_line_length': 92, 'alphanum_fraction': 0.7178060413354531, 'licenses': ['Apache-2.0'], 'repository_name': 'IEC-Elfred/MyTictok', 'path': 'app/src/main/java/com/example/mytictok/activity/FocusActivity.java', 'size': 1274, 'lang': 'Java'}