2017-04-04 44 views
1

我有我的菜單,我有十個項目,但準備好時,他們沒有完全顯示,只有每個項目的第一個字母。列表菜單時出錯xamarin android

我能做些什麼來解決它?

圖像0​​enter image description here

從我的菜單代碼,我只是有麻煩顯示文本完全

private void SetUpViewPager(ViewPager viewPager) 
{ 
    TabAdapter adapter = new TabAdapter(SupportFragmentManager); 
    adapter.AddFragment(new Fragment1(), "Início"); 
    adapter.AddFragment(new Fragment2(), "Serviços"); 
    adapter.AddFragment(new Fragment3(), "Cidade"); 
    adapter.AddFragment(new Fragment4(), "Polícia"); 
    adapter.AddFragment(new Fragment4(), "Cultura"); 
    adapter.AddFragment(new Fragment4(), "Esporte"); 
    adapter.AddFragment(new Fragment4(), "Geral"); 
    adapter.AddFragment(new Fragment4(), "Caderno de esportes"); 
    adapter.AddFragment(new Fragment4(), "Vedeos"); 
    adapter.AddFragment(new Fragment4(), "C Especiais"); 
    viewPager.Adapter = adapter; 
} 

public class TabAdapter : FragmentPagerAdapter 
{ 
    public List<SupportFragment> Fragments { get; set; } 
    public List<string> FragmentNames { get; set; } 

    public TabAdapter (SupportFragmentManager sfm) : base (sfm) 
    { 
     Fragments = new List<SupportFragment>(); 
     FragmentNames = new List<string>(); 
    } 

    public void AddFragment(SupportFragment fragment, string name) 
    { 
     Fragments.Add(fragment); 
     FragmentNames.Add(name); 
    } 

    public override int Count 
    { 
     get 
     { 
      return Fragments.Count; 
     } 
    } 

    public override SupportFragment GetItem(int position) 
    { 
     return Fragments[position]; 
    } 

    public override ICharSequence GetPageTitleFormatted(int position) 
    { 
     return new Java.Lang.String(FragmentNames[position]); 
    } 
} 
+2

你有沒有在你的'TabLayout' xml'app:tabMod e =「可滾動」和「app:tabGravity =」fill「'? – Yupi

+0

是----> JOSE

+0

它的工作原理,謝謝 – JOSE

回答

0

添加到您的TabLayout這行代碼:app:tabMode="scrollable"所以你的TabLayout代碼應該是這個樣子這個:

<android.support.design.widget.TabLayout 
    android:id = "@+id/tabs" 
    android:layout_width = "match_parent" 
    android:layout_height = "wrap_content" 
    app:tabGravity="fill" 
    app:tabMode="scrollable" />