0

Hi I have built a app using mvvmcross in ios using a custom container / controller and was wondering if there was something similar in android where I have a main view/activity with a defined layout and i push views inside a container on that view and keep navigation. I guess its similar to viewgroup. Mainly the purpose of this is to have the same layout on all views/activities, I am currently using a header xml file that is included in the view but was wondering if there is a better way of doing it.

Cheers

  • 1
    What exactly do you mean with "keep navigation"? One thing that comes to mind is to use fragments in your default layout. If you want to display something different just change the fragment. You will probably have a very large main activity with lots of methods due to all the possible actions of all your different fragments but it is possible. – Kaschwenk Apr 08 '14 at 05:52
  • In iOS you can have a "View" that has a container where you can swap in and our views so that you can keep the same layout on all views, e.g. an image/branding or buttons on the top. At this time I have about 15 .axml files which include a header but was just wondering if there was a better way of having to include that that header file on each view. –  Apr 08 '14 at 05:57
  • Is this helping? http://stackoverflow.com/questions/7916527/android-using-layouts-as-a-template-for-creating-multiple-layout-instances – Kaschwenk Apr 08 '14 at 06:06

1 Answers1

0

Fragment is the solution you are looking for. take a look on below links

http://developer.android.com/guide/components/fragments.html

http://www.vogella.com/tutorials/AndroidFragments/article.html

you may define your activity with two or more fragment. lets say you have header and body fragment here. now fix the header fragment for all screens where you want same header layout and keep navigating using different fragment in body section.

RQube
  • 954
  • 3
  • 13
  • 28