-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCategoryAdapter.java
More file actions
71 lines (63 loc) · 2 KB
/
CategoryAdapter.java
File metadata and controls
71 lines (63 loc) · 2 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.simpleapps22.dholuo;
import android.app.Fragment;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentPagerAdapter;
/**
* {@link CategoryAdapter} is a {@link FragmentPagerAdapter} that can provide the layout for
* each list item based on a data source which is a list of {@link Word} objects.
*/
public class CategoryAdapter extends FragmentPagerAdapter {
/**
* Context of the app
*/
private final Context mContext;
/**
* Create a new {@link CategoryAdapter} object.
*
* @param context is the context of the app
* @param fm is the fragment manager that will keep each fragment's state in the adapter
* across swipes.
*/
public CategoryAdapter(MainActivity context, androidx.fragment.app.FragmentManager fm) {
super(fm);
mContext = context;
}
/**
* Return the {@link Fragment} that should be displayed for the given page number.
*
* @return
*/
@NonNull
@Override
public androidx.fragment.app.Fragment getItem(int position) {
if (position == 0) {
return new VocabulariesFragment();
} else if (position == 1) {
return new Vocabularies1Fragment();
} else if (position == 2) {
return new ExtrasFragment();
} else {
return new PhrasesFragment();
}
}
/**
* Return the total number of pages.
*/
@Override
public int getCount() {
return 4;
}
@Override
public CharSequence getPageTitle(int position) {
if (position == 0) {
return mContext.getString(R.string.category_vocabularies);
} else if (position == 1) {
return mContext.getString(R.string.category_vocabularies1);
} else if (position == 2) {
return mContext.getString(R.string.category_extras);
} else {
return mContext.getString(R.string.category_phrases);
}
}
}