January 2014
Intermediate to advanced
736 pages
70h 43m
English
We override Activity method onCreateOptionsMenu (Fig. 5.21) to initialize Activity’s standard options menu. The system passes in the Menu object where the options will appear. In this app, we want to show the menu only when the app is running in portrait orientation. Lines 87–88 use the WindowManager to get a Display object that contains the screen’s current width and height, which changes based on the device’s orientation. If the width is less than the height, then the device is in portrait orientation. Line 89 creates a Point object to store the current width and height, then line 90 calls Display method getRealSize, which stores the screen’s width and height in the Point’s public instance ...
Read now
Unlock full access