gpt4 book ai didi

android - 如何像我想要的那样在android中设置小写的选项卡名称

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:23:31 26 4
gpt4 key购买 nike

我正在开发一个包含三个 fragment 选项卡的屏幕。选项卡标题只有大写的第一个字母:

 private String[] tabs = { "About Me", "Education","ProfileEdit"};

但是当我运行该应用程序时,标题全部以大写显示。

如何让标签正确显示单词?

标签设置代码:

  private String[] tabs = { "About Me", "Education","ProfileEdit"};

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.editprofile);
user=(UserModel)getIntent().getSerializableExtra("USER");
// Initilization
viewPager = (ViewPager) findViewById(R.id.pager);
actionBar = getActionBar();
mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

viewPager.setAdapter(mAdapter);
actionBar.setHomeButtonEnabled(true);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

// Adding Tabs
for (String tab_name : tabs) {
actionBar.addTab(actionBar.newTab().setText(tab_name.toLowerCase())
.setTabListener(this));
}

/**
* on swiping the viewpager make respective tab selected
* */
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

@Override
public void onPageSelected(int position) {
// on changing the page
// make respected tab selected
actionBar.setSelectedNavigationItem(position);
}

@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}

@Override
public void onPageScrollStateChanged(int arg0) {
}
});
}

@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}

@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// on tab selected
// show respected fragment view
viewPager.setCurrentItem(tab.getPosition());
}

@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
}

更新

我用 textAllCaps false 编辑了主题,但文字显示方式相同:

<resources>
<style name="MyTheme" parent="Theme.Sherlock">
<item name="actionMenuTextAppearance">@style/MyMenuTextAppearance</item>
<item name="android:actionMenuTextAppearance">@style/MyMenuTextAppearance</item>
</style>
<style name="MyMenuTextAppearance" parent="TextAppearance.Sherlock.Widget.ActionBar.Menu">
<item name="android:textAllCaps">false</item>
</style>

最佳答案

Android 4.0 中选项卡 View 的默认主题(Holo 主题)将 android:textAllCaps 设置为 true。见:

http://android-developers.blogspot.in/2011/04/customizing-action-bar.html

关于android - 如何像我想要的那样在android中设置小写的选项卡名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27522731/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com