1

I'm creating an android app that will have multiple pages with the same layout, but the only thing that changes will be a string that is displayed on the top (using setText). Can I use a different xml file in the same activity class.., or does Android not allow that?

AndroidDev
  • 4,521
  • 24
  • 78
  • 126
  • look here : http://stackoverflow.com/questions/6377446/in-android-can-i-have-different-activities-use-the-same-xml-file – user838522 Jul 22 '11 at 05:47
  • but here they have use sane activity and call different xml layout within that activity..but in my case i want opposite to that.. – AndroidDev Jul 22 '11 at 08:45

1 Answers1

1

No problem with that. You can use in the same activity as many XML layouts as you want. Simply switch between them using setContentView()

Barmaley
  • 16,638
  • 18
  • 73
  • 146
  • how that can be done..can you send me a simple example for that..one more thing is it possible to use setcontentView in another function instead of onCreate function – AndroidDev Jul 22 '11 at 07:03
  • @Anshuman: put it wherever you want... Myselft using setContentView on various places not only in onCreate() for instance in onClick() – Barmaley Jul 22 '11 at 09:40