简体   繁体   English

方向更改时Android中的ViewPagerIndicator问题

[英]Issue with ViewPagerIndicator in Android when orientation is changed

I have implemented the Jake Wharton's ViewPagerIndicator. 我已经实现了Jake Wharton的 ViewPagerIndicator。 Here, I am reloading the data when the orientation is changed. 在这里,当方向改变时,我正在重新加载数据。

In landscape I have 6 pages & I have scrolled to last page. 在横向中,我有6页,并且已经滚动到最后一页。 The result is here 结果在这里 这里

Now, I have changed the orientation to portrait. 现在,我将方向更改为纵向。 Now portrait has only 4 pages. 现在,Portrait只有4页。 But, the result is here. 但是,结果就在这里。

在此处输入图片说明

Here the indicator has gone out of the available items. 此处,指示器已超出可用项目。

But, the selected page is 1. 但是,所选页面是1。

How to resolve this issue? 如何解决这个问题? I have used the following line 我用了以下行

circlePageIndicator.setCurrentItem(0);

Even then its not working? 即使那样它不起作用?

circlePageIndicator.setCurrentItem(0); circlePageIndicator.setCurrentItem(0); selects page at position 1? 选择位置1的页面?

You most likely have android:configChanges="orientation" in your manifest which is preventing the activity from restarting on orientation changes. 您的清单中很可能有android:configChanges="orientation" ,这会阻止活动在方向更改时重新启动。 Because of this, certain fundamental aspects of the view are changing (eg, the width) and the control isn't updating properly since you prevent recreation. 因此,视图的某些基本方面正在发生变化(例如,宽度),并且由于无法防止重新创建,因此控件未正确更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM