0

I'm making an android app in which the controls cannot be fit in one page. I have created a new XML file with the remainder of controls. Currently I'm trying to switch between the pages like this:

setContentView(R.layout.main);
// initialize controls on main page
setContentView(R.layout.page2);
// initialize controls on second page

However I can't set or alter any of the controls on second page (no error is generated when trying to access those controls either). Is it necessary to make a new activity class for the second page?

If you need additional info to be provided, please comment it and I'll provide it.

Shaahin Sh
  • 165
  • 12

3 Answers3

1

You could fit all the controls inside a scrollable view.

(If you have two XML-files I would recommend that you have two activities as well.)

Michael Banzon
  • 4,879
  • 1
  • 26
  • 28
  • I looked into the class after reading your reply. It does the job but ViewFlipper does it more to my liking. Thanks! – Shaahin Sh May 07 '12 at 20:43
1

If you want to have multiple "pages" in one activity, have a look at ViewFlipper class. You can have two layouts representing two "pages" in one ViewFlipper parent - and then switch between the two.

Aleks G
  • 56,435
  • 29
  • 168
  • 265
0

You could use fragments to hold each of the layouts, and then switch. This would allow you to control from 1 activity class or from each of the fragment classes.

Tony
  • 2,335
  • 21
  • 25