-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTabsPagerAdapter.java
56 lines (44 loc) · 1.42 KB
/
TabsPagerAdapter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.android.iway.codersinc;
/**
* Created by IWAY on 25-09-2016.
*/
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import com.android.iway.codersinc.Contests.CollegeContests;
import com.android.iway.codersinc.Contests.CurrentContests;
import com.android.iway.codersinc.Contests.UpcommingContests;
import java.util.ArrayList;
import java.util.List;
public class TabsPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public TabsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int index) {
switch (index) {
case 0:
return new CurrentContests();
case 1:
return new UpcommingContests();
case 2:
return new CollegeContests();
}
return new CurrentContests();
}
@Override
public int getCount() {
// get item count - equal to number of tabs
return 3;
}
public void addFrag(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position);
}
}