I was just wondering if anyone has implementing anything like the following for Android. Suppose you have an interactive menu system but depending on the selections by the user different options could become available. I suppose it is sort of like a tree structure at the top maybe there are 3 choices but as you move down the tree the choices continue to grow? Is this making any sense? So in all maybe there ar开发者_JS百科e 150 different choices? Each tree has 50 options. Anyways...Instead of making tons of different layouts and menus for the different pages with options....Is there a way to maybe declare the options in an xml file or something then dynamically load or build the layouts depending on what the user chooses? Maybe some sort of driver? Has anyone done anything like this? So instead of having like 50 layouts they have a driver that builds these automatically. Thanks...this could be a shot in the dark.
Why don't you inflate layouts? I believe the best solution is to mix XML and code.
Declare ready-to-use View
s (or even full-featured layouts) as XMLs. Then create some code to grab those XMLs and update as needed. Then you add the layouts and Views accordingly to create the desired effect for each final "page" (glue the blocks together).
If you code (and design!) wisely, you can achieve a fairly slim code size by abstracting away all the similarities of the pages. And of course, there is a theoretical minimum as to how much code you'll need... it can only be as small as how simple the final effect needs to be.
精彩评论