开发者

How can i change layout when orientation is change

开发者 https://www.devze.com 2023-04-08 17:26 出处:网络
I want to change my blackberry screen GUI When i go from portrait to landscape mode. protected void sublayout(int width, int height) {

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号