You are probably looking for a ViewStub A ViewStub is an invisible, zero-sized View that can be used to lazily inflate layout resources at runtime. When a ViewStub is made visible, or when inflate() is invoked, the layout resource is inflated. The ViewStub then replaces itself in its parent with the inflated View or Views.... You can use this like a normal view in your layout and use findViewById() to reference it in code.
After that use ViewStub. SetLayoutResource() to set layout that you want to show and call ViewStub.inflate() to show it. This way you can write a normal XML layout file for every (sub-)page you need Also see this article Edit: Or probably not, I have to mention that the stub gets removed from the view hierachy after inflating.So, depends on your actual use case if this is helpful.
You are probably looking for a ViewStub. A ViewStub is an invisible, zero-sized View that can be used to lazily inflate layout resources at runtime. When a ViewStub is made visible, or when inflate() is invoked, the layout resource is inflated.
The ViewStub then replaces itself in its parent with the inflated View or Views. ... You can use this like a normal view in your layout and use findViewById() to reference it in code. After that use ViewStub.
SetLayoutResource() to set layout that you want to show and call ViewStub.inflate() to show it. This way you can write a normal XML layout file for every (sub-)page you need. Also see this article.
Edit: Or probably not, I have to mention that the stub gets removed from the view hierachy after inflating. So, depends on your actual use case if this is helpful.
Ok, so if I use that with ~ code ((ViewStub) findViewById(R.id. Page1)). SetVisibility(View.
VISIBLE); , will I just be able to change page1 to page2 and then page1 disappears? – scott. Smart Sep 10 at 6:48 No thats actually not the case, see my edit.
Forgot that the stub gets removed in the first place, so this is not useful in this case. But you might take a look at the ViewFlipper class. That allows you to display one of multiple sublayouts at a time and change them dynamically via ViewFlipper.
SetDisplayedChild(). – alextsc Sep 10 at 6:53 Chances are I'm looking at do-it-yourself kinda stuff I guess. Also, in the case of the article, what happens to the progress bar view when the file is done importing?
It would be a bit annoying if it happened to just stay there while the user kept trying to scroll for more books... but if it does fade out, then how do you get it back? – scott. Smart Sep 10 at 6:56 I'm not familiar with that app, so this is a guess: After the bar is inflated (which is the expensive operation to avoid if not needed) and used, they probably hide it via setVisibility(View.
GONE). This way it can still be reused without inflating again by changing the visibility back to View.VISIBLE. And with GONE, the thing does not take any space, which results in no resource costs while rendering the whole layout.
– alextsc Sep 10 at 7:02 I don't think ViewFlipper is quite the way to go as I currently have only 11 pages, but with future expansions on the project I hope to have a few hundred pages for different usergroups and product sets. Think about 10 to 20 pages per product set per usergroup. I would prefer to navigate those in separate files as opposed to one 5000 line file.
Thanks for your knowledge though, I'll look into making some modifications and see if I can make some use of the ViewFlipper for some of the other layouts I have. – scott. Smart Sep 10 at 7:03.
I am attempting to create a program with a set of dynamically loaded layout "pages". I have the base layout created with a minimal default skeleton of the Views common to each page. For each page I was going to hard code all the views to be swapped (:facepalm).
My next thought was to create a text file and put the necessary data in a well formatted design. Only then I realized that's exactly what the XML files are. So what I would like to do is create an XML file of the pages with the data exactly as it would appear in the original layout file.
Then as each page is loaded (possibly unload another page), pull the XML data for that page and insert it into the current base layout structure. I am new to Android programming and have only a little experience in generating interfaces from XML. In programming C# and XML for a previous job, I would have to pull the data directly from an embedded XML file and use that to create the Button or TextBox myself.
Do I need to do similar in this case or is there a way to automatically load it? I have looked this up for a while and most answers I found on this site and other places are from months ago or longer. Those answers tend to range from IMPOSSIBLE to do it yourself.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.