我的菜单里面有十件物品,但是当他们准备好时,它们并没有完全出现,只有每件物品的第一个字母。
我能做些什么来解决它?
我的菜单中的代码,我只能完全显示文本
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]);
}
}
答案 0 :(得分: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" />