How do I prevent an Activity from being re-created? Is it to call it only once?

1

I am making a form and when I finish filling out the form I need to change the color of the item in a ListView with the name of the form I just filled out and leave the color there independent if I am browsing the application and going through the various activity Sometimes, does anyone know how to do this? lets onCreate be called only once.

    
asked by anonymous 09.09.2015 / 17:25

2 answers

1

I believe that trying to change the life cycle of Activity will not be very successful.

What you can do is to save your information in a static variable, so regardless of whether% is created or not, the value will always be the same. Example:

public static ArrayAdapter meu_adapter;

So your Activity will always keep the information, regardless if the Adapter is destroyed and created.

If there is a need to keep the colors after the App closure I recommend saving the records to a Activity database.

    
18.09.2015 / 15:19
0

You can do the following, every time you finish filling out the form you change your listview adapter and call the meu_adapter.notifyDataSetChanged() method.

I replied something similar here link

    
18.09.2015 / 15:15