当我选择标签菜单时,如何更改android操作栏标题?
答案 0 :(得分:1)
在 onPageSelected()中,尝试使用以下代码
getSupportActionBar().setTitle("My Title");;
这可能对你有所帮助。
答案 1 :(得分:0)
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);
}
}