Nullpointerexception: Attempt To Invoke Virtual Method 'void Android.support.v4.app.fragment.setmenuvisibility(boolean)' On A Null Object Reference
I am trying to implement viewpager with Tablayout. In this everything is fine working properly, but the one problem is when i come back from another screen view pager lost their po
Solution 1:
Your code is right you only have to change the placement of code put your
tabLayout.setupWithViewPager(viewPager);
,
tabLayout.addTab(tabLayout.newTab().setText("Websites"));
tabLayout.addTab(tabLayout.newTab().setText("Mobile Application"));
tabLayout.addTab(tabLayout.newTab().setText("Graphics"));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
after setadapter in viewPager
viewPager.setAdapter(adapter);
viewPager.setOffscreenPageLimit(3);
Post a Comment for "Nullpointerexception: Attempt To Invoke Virtual Method 'void Android.support.v4.app.fragment.setmenuvisibility(boolean)' On A Null Object Reference"