Android layout with different items on landscape and on portrait?

Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)). GetDefaultDisplay(); @Override public void onConfigurationChanged(Configuration newConfig) { super. OnConfigurationChanged(newConfig); if(display.getOrientation() == 0) setContentView(R.layout.

Main_portrait); else setContentView(R.layout. Main_landscape); //getOrientation gives 1 here }.

You would give the View pager in the above if/else statement. – Graeme Oct 26 at 12:20 Although I would suggest instead creating a res/values-land/integer. Xml and res/values-port/integer.

Xml which would allow you specify s in the same layout xml rather than possibly duplicating functionality by creating two layout files. – Graeme Oct 26 at 12:22 So what you're saying is there isn't a way to do it with res/layout-land and res/layout? – Kalisky Oct 26 at 13:03.

You could make two layout files and at the beginning of your onCreate() (just after super. OnCreate(bundle) line), put an if/else statement around this line: setContentView(R.layout. Main); to look like this: if(orientation==LANDSCAPE) setContentView(R.layout.

Main_landscape); else setContentView(R.layout. Main_portrait); and from then on, wherever your java code would be different, just wrap it in the same condition. It's a little long-winded if your java code is very dependent on being in portrait, but I can't think of a better solution atm.

Also, depending on your application and it's functionality, you may need to recreate the activity on orientation change. But again, it may not be necessary. I hope this helps.

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.

Related Questions