You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The application contains 3 tabs - Home, About and FAQ. Within About tab, I've 2 more tabs namely - User details and Privacy Policy. Each of these will load a fragment into viewpager. Below is relevant code I am having now.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view=inflater.inflate(R.layout.fragment_about, container, false);
new Thread(new Runnable() {
@Override
public void run() {
initUI(view);
}
}).start();
return view;
}
private void initUI(View view) {
final ViewPager viewPager = (ViewPager) view.findViewById(R.id.about_horizontal_tab);
ViewPagerAdapter adapter = new ViewPagerAdapter(getActivity().getSupportFragmentManager());
adapter.addFrag(new UserDetailsFragment(), "User Details");
adapter.addFrag(new PrivacyPolicyFragment(), "Privacy Policy");
viewPager.setAdapter(adapter);
final NavigationTabStrip navigationTabStrip = (NavigationTabStrip) view.findViewById(R.id.nts_top);
navigationTabStrip.setViewPager(viewPager, 0);
}
ViewPagerAdapter.java
public class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public ViewPagerAdapter(FragmentManager manager) {
super(manager);
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
public void addFrag(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position);
}
}
But contents within About tab's, User Details and Privacy Policy never loads even though, when debugged, it hits the respective fragment's onCreateView method. Similarly, when I navigate to Privacy Policy tab it gets stuck there and doesn't navigate back to User Details tab on click.
How could I possibly solve this issue? Is it supported to have nested tabs in android?
The text was updated successfully, but these errors were encountered:
The application contains 3 tabs - Home, About and FAQ. Within About tab, I've 2 more tabs namely - User details and Privacy Policy. Each of these will load a
fragment
intoviewpager
. Below is relevant code I am having now.HomeActivity.java
AboutFragment.java
ViewPagerAdapter.java
But contents within About tab's,
User Details
andPrivacy Policy
never loads even though, when debugged, it hits the respective fragment'sonCreateView
method. Similarly, when I navigate toPrivacy Policy
tab it gets stuck there and doesn't navigate back toUser Details
tab on click.How could I possibly solve this issue? Is it supported to have nested tabs in android?
The text was updated successfully, but these errors were encountered: