You can use fragments, especially 1 type of Fragment called ' LevelFragment', which will contain several arguments that you can pass to it so that each level is different, these arguments should refer to the contents of the level (background or something else). This way, you reuse the same layout and the same logic, simply modifying some of them based on the arguments you have.
Now all you have to do is swap fragments in the container, remaining in only one action. Since your question was fuzzy, I can not offer any recommendations for implementation at this stage, but rather a basic guide and a guide for consideration.
source
share