Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems with Android FragmentActivity and Tabs
    text
    copied!<p>I have successfully converted my TabActivity into a FragmentActivity, with the tab content being Fragments. I am running two issues:</p> <ol> <li><p>Each of my tabs contain EditText's. When I change the value of an EditText on TAB1, switch to TAB2, and then switch back to TAB1, the value of the EditText has been reset.</p></li> <li><p>If start a new activity from one of my tab Fragments, and then go back to the existing FragmentActivity, then the tab content disappears. I was originally having this issue when using a TabHost, which is why I spent the time to convert everything to Fragments...</p></li> </ol> <p>Regarding #1, I'm assuming the issue has to do with savedInstanceState. I followed Google's <a href="http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabs.html" rel="nofollow">example</a> exactly, using the following in onCreate() of my FragmentActivity:</p> <pre><code>initialiseTabHost(savedInstanceState); if (savedInstanceState != null) { mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); } </code></pre> <p>Additionally, here is my onSaveInstanceState() method of my FragmentActivity:</p> <pre><code>protected void onSaveInstanceState(Bundle outState) { outState.putString("tab", mTabHost.getCurrentTabTag()); super.onSaveInstanceState(outState); } </code></pre> <p>Here is what one of my tab Fragment's looks like:</p> <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { return null; } return (LinearLayout) inflater.inflate(R.layout.priority_boxes_tab, container, false); } public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setRetainInstance(true); ArrayList&lt;Supply&gt; list = new ArrayList&lt;Supply&gt;(); // More code here } </code></pre> <p>Should I be doing anything else? I have about 15 EditText fields on the screen. Do I need to somehow save all of those values and set it so that the fields will repopulate with those values the next time?</p> <p>Regarding #2, I have no idea what else I can do. Does anyone have any suggestions?</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload