-1

I have an application that does this : When the application starts,one row with 3 editTexts is created by calling a method called newproduct().The first of them is focused and this triggers the creation of another row of those 3 edittexts.So,when the last row is focused,another row is created dynamically. Every columns is inside a different linear layout and gets added to a new ArrayList<EditText>();,one for everyone of the 3 columns.The values that get entered are then put inside a String[],again,3 of them for every column.

My questions now are the following : 1.How can i save this on screen orientation changes? When i change the orientation,the values remain but only in two of the rows because those 2 rows are created at onCreate( newproduct method called,creates the first row, and then focused,so it creates another row).How can i tell my application to create more then 2 rows and keep the values ?

2.How can i make my application keep everything,the number of rows and their values and the whole UI layout when the user either exits the app or the app crashes.What i want here is when he enters the app again to see the state in which the app was left the last time.

Thanks in advance and have a nice day !

Sorin Grecu
  • 1,036
  • 11
  • 30
  • Simon,how do i retain the number of dynamically created EditTexts and then recreate them? If they were static,created thru a layout it would've been easier but what do i do in my situation ? – Sorin Grecu Jul 17 '13 at 16:25
  • Is your question now "how to save arrays to a `Bundle`? – Simon Jul 17 '13 at 16:30
  • As i said,currently,with no special method like `savedInstanceState` or anything like that,my app,when the orientation is changed,will only recreate 2 of the EditText rows which are called in onCreate.My question is,if i use something like `savedInstanceState` will it do the same thing ? do i need to do something to recreate all the dynamic EditTexts ? or are they going to get recreated automatically ? – Sorin Grecu Jul 17 '13 at 16:35

2 Answers2

0

You need to save the Bundle instance for the activity. Check this link for further insight. Saving bundle

Community
  • 1
  • 1
Kunal S. Kushwah
  • 883
  • 1
  • 8
  • 19
0

You must use a Bundle instance for the activity. You can take a look at this article on Google Developers Recreating an Activity

amatellanes
  • 3,645
  • 2
  • 17
  • 19