I'm creating a SlidingPageLayout but it does not have icons. I'm setting a viewPager for this slidingpageLayout. The viewpager has a PagerAdapter and PagerAdapter sets the title of the page. I want to set an icon instead of a text. Reference question: Android SlidingTabLayout with icons
Asked
Active
Viewed 4,244 times
4
1 Answers
0
would something like this work for you
Actionbar mActionbar = getActionbar();
mActionBar.setTitle("");
mActionBar.setIcon(getResources().getDrawable(R.drawable.icon1))
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@SuppressLint("NewApi")
@Override
public void onPageSelected(int position) {
mViewPager.setCurrentItem(position);
switch (position) {
case 0:
mActionBar.setIcon(getResources().getDrawable(R.drawable.icon1))
break;
case 1:
mActionBar.setIcon(getResources().getDrawable(R.drawable.icon2))
break;
default:
mActionBar.setIcon(getResources().getDrawable(R.drawable.icon1))
break;
}
}
});

zoruc
- 819
- 7
- 13
-
My Sliding table Layout setup: http://pastebin.com/EM01Ai2d My View Pager code: http://pastebin.com/HjwTjVEX – user1159517 May 02 '14 at 06:43