Posts tagged active state
Android – Java Avoid Deleting Then Recreating
May 1st
If an application has an object that has been created, and displayed to the screen then it is deleted, it cannot be immediately recreated. Recent experience tells me that either the variable has to be re-initialized or use another technique to remove it from the screen. Lets say there are 10 buttons on the screen. Only 2 of them are to be displayed. Each button can have a settings variable that referrs to the buttons active state that can in turn set the objects visibility. For example:
By default all buttons will be off. Then to display a new button toggle the on/off setting and update the view with show/hide methods of the respective class (ie. TableLayout, TableRow). All you really have to do is hide the TableRow and not the object in it. Just remeber when you hide the row reset the settings of the respective option to default.