I change the layout in my App for different reasons like,a settings or about sub-layout.
But when I go back to the main layout, every setting there is gone: no Buttonlistener is set anymore and the EditTextfields do contain the standart text.
How can I change that behaviour? Is there some other function like onConfigurationChanged()
, which handles "inside" calls of a layout in an action?
Asked
Active
Viewed 140 times
0

Sim
- 4,199
- 4
- 39
- 77
-
Think some of your code might be useful to include here - certainly the ideas that you describe work for me without hassles and without removing my listeners. – Elemental Sep 27 '11 at 13:00
-
Sure, but i don't know what code to include else i would have done it. Can you change forth and back between different layouts without loosing settings within the different layouts? Like the standart texts appear instead of the ones tiped by the user? (It works when i just leave the app though) – Sim Sep 27 '11 at 13:03
-
How are you changing the layout and changing it back? – DeeV Sep 27 '11 at 13:20
-
in the usual way `setLayout(R.id.anyone)`, and back it is the same way. I already tried to set the text within that buttonhandler. But sadly no effekt. – Sim Sep 27 '11 at 13:30
-
i partially figured it out. I can counter that effect wiht explicitly loading the resources by id and changing them IN the buttonhandler. But then you have to save and load them every time you call any layout function. There has to be another way, which is more elegant. – Sim Sep 27 '11 at 13:55
1 Answers
0
Well due to the fact nobody answered yet and i did figured it out, i'll post my Solution as an answer even though I suspect there might be a more elegant way:
Every time you change a layout using setLayout(...)
you first have to save your configuration like described here. Then when you change back to the "old" layout you have to get your resources dynamicly and load and set the old settings like:
edit_text_one = (EditText) findViewById(...);
edit_text_one.setText(settings.getString("text","text"));

Sim
- 4,199
- 4
- 39
- 77