I need to hide first tab. First page should work but when user select it, it should be seems like on tabs is selected. How I can do this?
I found some solutions with TabHost and it useless to me.
public class TabFragmentClients extends Fragment {
public static TabLayout tabLayout;
public static ViewPager viewPager;
public static int int_items = 5 ;
FinanceClients FinanceClients;
public ClientsFragment clientsFragment;
public FinanceFragment financeFragment;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
/**
*Inflate tab_layout and setup Views.
*/
final View x = inflater.inflate(R.layout.tab_layout_clients,null);
tabLayout = (TabLayout) x.findViewById(R.id.tabs);
viewPager = (ViewPager) x.findViewById(R.id.viewpager);
/**
*Set an Apater for the View Pager
*/
viewPager.setAdapter(new MyAdapter(getChildFragmentManager()));
/**
* Now , this is a workaround ,
* The setupWithViewPager dose't works without the runnable .
* Maybe a Support Library Bug .
*/
tabLayout.post(new Runnable() {
@Override
public void run() {
tabLayout.setupWithViewPager(viewPager);
}
});
return x;
}
Did you try this?
tabLayout.setupWithViewPager(viewPager);
tabLayout.removeTabAt(0);
tabLayout = (TabLayout) findViewById(R.id.tabs);
((ViewGroup) tabLayout.getChildAt(0)).getChildAt(desiredPosition).setVisibility(View.GONE);//hides the tab
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With