简体   繁体   English

Android使用ViewPager实现片段

[英]Android implementing fragments with a viewpager

I'm considering modifing my app using fragments with a viewpager, instead of activities. 我正在考虑使用带有Viewpager的片段而不是活动来修改我的应用程序。

So, as I understand the situation, I should be able to modify my app, that it just contains one main-activity which contains viewpager and to this viewpager I can and and remove Fragments as I like it, is that correct? 因此,据我所知,我应该能够修改我的应用程序,使其只包含一个包含viewpager的main-activity,并且我可以并向此viewpager删除我喜欢的Fragments,对吗?

If I am correct has someone maybe a link with a short example implementation (main-class + methods for adding and removing fragments). 如果我是正确的话,也许有人可以链接到一个简短的示例实现(主类+添加和删除片段的方法)。
... ...
If I am not correct can someone give me a hint what the cleanest implementation for such a problem would be. 如果我不正确,那么有人可以给我一个提示,以解决这种问题的最佳方法是什么。

Already thanks for your time and support. 感谢您的时间和支持。

Check out the example on the ViewPager documentation it shows the usage with Fragments: 查看ViewPager文档上的示例,该示例显示了Fragments的用法:

https://developer.android.com/reference/android/support/v4/view/ViewPager.html https://developer.android.com/reference/android/support/v4/view/ViewPager.html

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

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