[英]How to re-use same fragment across viewPager
I have a fragment
with a textView
. 我有一个
textView
的fragment
。 I want the textView
to change when I scroll across the viewPager
.I want to reuse the same fragment
rather than creating a new fragment for displaying each text
.How do I do this? 我希望
textView
改变,当我遇到了滚动viewPager
。我想重复使用相同的fragment
,而不是创建用于显示每个新片段text
我这样做。如何? I hope pro developers can understand what I mean. 我希望专业开发人员能够理解我的意思。
You cannot attach a same fragment into activity twice simultaneously. 您不能将同一片段同时两次附加到活动中。 If you want the behavior you mentioned don't use
ViewPager
. 如果您想要的是您提到的行为,请不要使用
ViewPager
。 Just use swipe gesture detection in a layout and maybe some animations. 只需在布局和某些动画中使用滑动手势检测即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.