简体   繁体   English

如何使用选项卡菜单更改 android 操作栏标题?

[英]How do I change the android actionbar title with tab menu?

选择标签菜单时如何更改android操作栏标题?

In your onPageSelected() , try following code,在您的onPageSelected() 中,尝试以下代码,

 getSupportActionBar().setTitle("My Title");;

This may helps you.这可能对您有所帮助。

public class TabAdapter extends FragmentPagerAdapter implements ActionBar.TabListener , ViewPager.OnPageChangeListener{
   int resId = {R.drawable.position0, R.drawable.position1, R.drawable.position2, R.drawable.position3, R.drawable.position4};

 @Override
public void onPageSelected(int position) {
    mActionBar.setSelectedNavigationItem(position);
    int resIdLenght = resId.length;
    if (position < 0 || position >= resIdLenght)
            return;
    int drawableId = resId[position];
    mActionBar.setIcon(drawableId);  
}


}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何更改android操作栏的标题和图标 - How do I change the android actionbar title and icon 如何通过单击选项卡更改操作栏菜单按钮 - How to change actionbar menu button with click on tab 如何在运行时更改Android Actionbar Stackedbar标签的样式? - How do I change the style of the Android Actionbar Stackedbar's tab at runtime? 如何在 Android Studio 中将 ActionBar 标题居中? - How do I center the ActionBar title in Android Studio? 如何在 Android(使用 Nativescript)中将 ActionBar 标题文本居中? - How do I center ActionBar title text in Android (with Nativescript)? 如何强制拆分ActionBar的标签和标题/主页/菜单? - How to force splitting ActionBar's Tab and Title/Home/Menu? Android ActionBar自定义视图和标题通过选项卡导航更改。 - Android ActionBar custom view and title change with tab nevigation. 安卓 动作栏。 如何更改ActionBar标题颜色? - Android. ActionBar. How to change ActionBar title color? 如何更改ActionBar菜单背景颜色(android 4&5) - How to change ActionBar menu background color (android 4 & 5) 如何在Android的ActionBar中更改DrawerArrowToggle(汉堡包)的颜色? - How do I change the color of the DrawerArrowToggle (hamburger) in ActionBar in Android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM