i'm trying to create an Fragment with a tabs first the main Activity has a bottom navigation with 4 fragments. 1 of the fragments i want to make a tabs which will insert another Fragment so basically the Fragment has a tabs with Fragment
and i have Class MyPagerAdapter here is the java file
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View pop = inflater.inflate(R.layout.fragment_adopt,
container, false);
TabLayout tabLayout = (TabLayout) pop.findViewById(R.id.tablayout);
tabLayout.addTab(tabLayout.newTab().setText("DOGS"));
tabLayout.addTab(tabLayout.newTab().setText("CATS"));
tabLayout.setTabGravity(tabLayout.GRAVITY_FILL);
final ViewPager viewpager = (ViewPager) pop.findViewById(R.id.pager);
final PagerAdapter adapter = new MyPagerAdapter.(getSupportFragmentManager().tablayout.getTabCount()) ;
ViewPager.setAdapter(adapter);
ViewPager.setOnPageListener(new tabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewpager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
return inflater.inflate(R.layout.fragment_adopt,container,false);
}
@Override
public void onFragmentInteraction(Uri uri) {
}
The problem is that the GetSupportFragment doesn't funtioning thank you for answering and Godbles
The definition of getChildFragmentManager() is:
Return a private FragmentManager for placing and managing Fragments inside of this Fragment.
The definition of getSupportFragmentManager() :
Return the FragmentManager for interacting with fragments associated with this fragment's activity.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.