简体   繁体   English

ActionBarSherlock片段和选项卡

[英]ActionBarSherlock Fragments and Tabs

I'm new at Android Development, but I want to start with it. 我是Android开发的新手,但我想从它开始。 I've currently a problem, I searched for hours, but I couldn't find a solution. 我目前遇到问题,我搜索了几个小时,但找不到解决方案。

Currently I used this tutorial: http://arvid-g.de/12/android-4-actionbar-with-tabs-example 目前,我使用了本教程: http : //arvid-g.de/12/android-4-actionbar-with-tabs-example

I implemented it with ActionBarSherlock, it worked like expected, but I want that after switching the tabs and then when switching back to a Tab what was already initialized, that it doesn't get reinitialized, they should open the same View as it was. 我用ActionBarSherlock实现了它,它的工作与预期的一样,但是我希望在切换选项卡之后再切换回Tab时,已经初始化的东西不会被重新初始化,他们应该打开与原来相同的View。

How I realize this? 我怎么知道的? If there is an example to show how it is realized it would be a lot easier to understand. 如果有一个示例说明如何实现,那么将更容易理解。

If I understand correctly, each Tab of the application is a Fragment, to switch back to a tab to its state after initialisation, you must 'restore' the state of the fragment once you come back to it. 如果我理解正确,那么应用程序的每个选项卡都是一个片段,要在初始化后切换回其状态,您必须在返回到片段之后“还原”该片段的状态。

This stackoverflow question highlights how you can restore the state of the Fragment: android fragment- How to save states of views in a fragment when another fragment is pushed on top of it 这个stackoverflow问题突出显示了如何还原Fragment的状态: androidfragment-如何在将另一个片段推到片段之上时如何保存片段中视图的状态

Of course, all this is documented in the Fragment guide: http://developer.android.com/guide/components/fragments.html 当然,所有这些都记录在Fragment指南中: http : //developer.android.com/guide/components/fragments.html

Do let me know if you have more questions 如果您还有其他问题,请告诉我

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

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