How to determine the screen orientation of the G1

Put your problem here if it does not fit any of the other categories.

How to determine the screen orientation of the G1

Postby arvishreef » Sat May 30, 2009 8:51 am

Hello,


I have 2 arrays of images. one is for landscape images and the other is for portrait images.
I want the G1 to know which images to load when the activity is first created depending on the orientation
of the G1. the orientation can either be landscape or portrait. If anyone have any ideas , let me know.





Thanks in advance,
arvishreef
Freshman
Freshman
 
Posts: 9
Joined: Mon May 04, 2009 6:18 am

Top

Postby Moons » Sun May 31, 2009 9:44 am

The answer could be in the Context class doc
Moons
Developer
Developer
 
Posts: 25
Joined: Fri Feb 13, 2009 9:19 pm

Postby Couillette » Sun May 31, 2009 9:22 pm

With android 1.5 there is a way to automatically load the needed image when rotation occurs, without any programming.
Look at the Lunar Landler source code.
You have to make two directories into res :
# drawable-land/
# drawable-port/

Then you put a file with the same name in each one, and when you will load the resource with the R class, it will automatically load the one corresponding to the rotation of the phone.

Bye.
Couillette
Freshman
Freshman
 
Posts: 6
Joined: Fri May 22, 2009 11:57 am
Location: France

Postby padde » Mon Jun 01, 2009 2:36 am

to get the actual orientation use this line in your activity
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. int orientation = this.getWindowManager().getDefaultDisplay().getOrientation();
  3.  
  4.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 8 guests