[英]How do I change the android actionbar title with tab menu?
選擇標簽菜單時如何更改android操作欄標題?
在您的onPageSelected() 中,嘗試以下代碼,
getSupportActionBar().setTitle("My Title");;
這可能對您有所幫助。
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.