How can i change layout when orientation is change
I want to change my blackberry screen GUI When i go from portrait to landscape mode.
protected void sublayout(int width, int height) {
// TODO Auto-generated method stub
if(D开发者_JAVA百科isplay.getOrientation()==Display.DIRECTION_PORTRAIT)
{
label.setText("Portrait");
}
else
{
label.setText("Landscape");
}
super.sublayout(width, height);
}
any help would be appreciated
Override sublayout on your screen, this is called whenever the orientation changes so you can use it to add/remove/change fields.
You can also use Display.getOrientation() to check the current orientation. You should also track the previous orientation within your application in case sublayout was called for a different reason.
You need to handle it manually. Whenever orientation changes in blackberry it calls the subLayout() method. There you can call invalidate method which will refresh your screen. But make sure that you are using relative layout instead of absolute layouts. It will automatically arrange the UI elements in your screen.
精彩评论