English 中文(简体)
重建 - 查看 Pager - 碎块PagerAdapter 的碎块
原标题:Recreate Fragment of - View Pager - FragmentPagerAdapter

我在申请时使用V4图书馆的 ViewPager

  1. 在主屏幕中,我有一个查看器Pager, 最大5个碎片, 所有碎片都属于一个类 文章Pager

  2. 现在在主屏幕上,有分类列表, 现在传呼机的内容是基于此选择,

我面临的问题是,我使用了存储碎片的 < code> FragmentPagerAdapter 。 如果碎片已经存在, 它会返回旧的碎片, 而不重造它。 事情运行得完美, 但是问题代码@ 方向改变的时间 。

例如

如果每个碎片中通常有 5 视图, 则给定位置, 但也有一些含有 2-3 视图 。 如果我在 第 页中“ 强” 更改方向 < 强” / “强”, 则“ 强” 。

所以,到现在,第5页的每一个类别中,我都会得到包含3种观点的观点,这不是我想要的。

在我的申请表中,每一类别都包含页数

<强> 是否有办法可以让我在点击分类时销毁和重新生成碎片? 或任何其他围绕工作。

谢谢

最佳回答

OK 多亏了开放源码 我找到了我的解决方案 http://code.google.com/p/openintents/source/browse/trunk/compatibility/AndroidSupplyV2/src/android/support/v2/app/FragmentPagerAdapter.java?r=3488" rel="noreferr"\\code >FraggermentPaggerAdapter 我推翻了方法 instantiateTroup 并得到了解答。

这很容易通过Fraferment StatePagerAdapter 来实现。 它总是重新创建它, 但我不想在每页的100秒里保存, 因为只有几页。

问题回答

所以,如果我理解正确的话, 你的问题是,在旋转后, 一组错误的碎片在您 ViewPager 中?

您为什么不检查您活动的Resume () 或 Start () 中当前选中的标签, 并创建/ 指定一个新的 PagerAdapter 来为您使用正确的碎片显示 ViewPager?





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签