5
隱藏標籤我需要隱藏第一個標籤。第一頁應該可以工作,但是當用戶選擇它時,它應該看起來像在選項卡上被選中。我如何做到這一點?的Android如何從TabLayout
我發現TabHost這對我沒用一些解決方案和。
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;
}
你能解釋一下你的問題? –
實際上有5個選項卡。我需要其中4個可見和1個隱藏。第一個標籤應該像屏幕一樣。 – Tolyas
檢查[此](http://stackoverflow.com/questions/5026653/how-to-hide-a-tab-in-android-tab-layout)溶液。它使用tabHost,也許你錯了! –