onPageSelected doesn't work for first page

前端 未结 10 1995
[愿得一人]
[愿得一人] 2021-01-30 12:30

My pager adapter ( extends PagerAdepter ) has a textview in it. And I update this textview with MainActivity\'s onPageSelected . Its update textview for position > 0 , but start

10条回答
  •  孤街浪徒
    2021-01-30 13:18

    It seems to me that what you really want to be doing is overriding getPageTitle(), and then, somewhere else, grabbing that page title and setting it as a TextView's text.

    That way when you initialize your activity, initialize the PagerAdapter and call getTitle(0). This will get you the title for page 0. Now set that in the Activity's textview. Later, whenever you change pages just call getTitle(newPosition) and update that TextView.

提交回复
热议问题