2.
Invoke
net.rim.device.api.system.Display.getOrientation()
.
int orientation = Display.getOrientation();
Restrict the touch screen direction
1.
Import the following classes:
•
net.rim.device.api.ui.Ui
•
net.rim.device.api.ui.UiEngineInstance
2.
Invoke
net.rim.device.api.ui.Ui.getUiEngineInstance()
.
UiEngineInstance _ue;
_ue = Ui.getUiEngineInstance();
3.
Invoke
net.rim.device.api.ui.UiEngineInstance.setAcceptableDirections(byte flags)
and pass the argument for the direction of the
Screen
.
_ue.setAcceptableDirections(Display.DIRECTION_WEST);
Receive notification when a drawable area of the touch screen changes
1.
Import the
javax.microedition.lcdui.Canvas
class.
2.
Extend
javax.microedition.lcdui.Canvas
.
3.
Override
Canvas.sizeChanged(int, int)
.
protected void sizeChanged(int w, int h) {
Dialog.alert("The size of the Canvas has changed);
}
}
Receive notification when the orientation of the touch screen changes
1.
Import the
net.rim.device.api.ui.Manager
class.
2.
Invoke
net.rim.device.api.ui.Manager.sublayout(int, int)
.
protected void sublayout(int width, int height) {
int x = 0;
int y = 0;
Field field;
int numberOfFields = getFieldCount();
for (int i=0; i<numberOfFields; ++i) {
field = getField(i);
layoutChild(field, width, height);
setPositionChild(field, x, y);
field.setPosition(x,y);
Development Guide
Touch screen orientation and direction
11