I have an add button and a GridLayout with 6 slots in it, when I click the add button, view1 is added to the gridlayout, I click the add button, view2 appears again, etc.
if (!theLayout1.isShown()) { Grid.addView(theLayout1); } else if (!theLayout2.isShown()) { Grid.addView(theLayout2); } else if (!theLayout3.isShown() ) { Grid.addView(theLayout3); } ..... // this goes on
after adding the view. I check if its text has already been added to sharedPrefs so that they can be automatically added when the action is recreated.
if (prefs.getString("text4", null) != null) { Grid.addView(theLayout4); } if (prefs.getString("text5", null) != null) { Grid.addView(theLayout5); }
My problem is that if I delete view1 and then add it again, it will be placed in the last slot as I want it, but when I recreate the action, it will return to first place, because since the code gets read in in his order, he will add the submission in their original order.
I want to add representations when I recreate the activity in the order in which they were before the operation was completed, this may have a simple logical solution, or maybe I just very poorly approach this problem, in any case I need help!
java android android-layout logic
John sardinha
source share