ViewPager - Changing the Up button Icon Depending on the Current Page

android android-viewpager

47 просмотра

1 ответ

923 Репутация автора

I'm attempting to change the up button icon depending on the current page in a ViewPager. For the first page I wish to display a cross icon and all subsequent pages to display the back arrow I have attempted the following in each fragment:

public void onCreate(Bundle savedInstanceState) {

    ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();


Unfortunately the icon does not change

Автор: TheKingOfAtlantis Источник Размещён: 22.08.2016 09:16

Ответы (1)

2 плюса

178 Репутация автора


You can use ViewPager.OnPageChangeListener and based on the position of the selected page in view pager you can change the appropriate icon. check the below link

Let me know for any further help.

Автор: rahul Размещён: 22.08.2016 09:35
Вопросы из категории :