-
Notifications
You must be signed in to change notification settings - Fork 0
/
ThirdFragment.java
37 lines (30 loc) · 1.21 KB
/
ThirdFragment.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
package test.ojassoft.com.ys;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class ThirdFragment extends Fragment {
private TabLayout tabLayout;
private ViewPager viewPager;
View view;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_main, container, false);
viewPager = (ViewPager) view.findViewById(R.id.viewpager);
addTabs(viewPager);
tabLayout = (TabLayout) view.findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
return view;
}
private void addTabs(ViewPager viewPager) {
PageviewAdapter adapter = new PageviewAdapter(getChildFragmentManager());
adapter.addFrag(new MMFragment(), "Men");
adapter.addFrag(new WWFragment(), "Women");
adapter.addFrag(new KKFragment(), "Kids");
viewPager.setAdapter(adapter);
}}