更改黑莓屏幕方向? [英] Change the Screen Orientation in Blackberry?

查看:105
本文介绍了更改黑莓屏幕方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的申请,我希望根据方向来显示屏幕。我知道,只要设备是面向和 sublayout()当前屏幕的方法被调用。根据这种观点我写的是这样的:

In my Application, I want to show the screens according to the Orientation. I knew, Whenever the device is Oriented then sublayout() method of current screen is called. According that point of view I write like this:

下面的启动是另一个的className;

Here StartUp is another className;

这是我的 LoadingScreen.java 类;

public class LoadingScreen extends MainScreen
{
public LoadingScreen()
{       
    createGUI();
}

protected void sublayout(int width, int height) 
{
    StartUp.screenOrientation();        
    if(StartUp.isLandscape)
    {
        deleteAll();
        createGUI();            
        invalidate();           
    }
    else
    {   
        deleteAll();
        orientGUI();            
        invalidate();
    }
    super.sublayout(width,height);  
}

public void createGUI()
{
    //For LANDSCAPE Display;
}

public void orientGUI()
{
    //For PORTRAIT Display;
}   
}

screenOrientation()方式是这样的:

public static void screenOrientation()
{
    if(Display.getOrientation()==Display.ORIENTATION_LANDSCAPE)     
    {
        isLandscape=true;
        width=480;
        height=360;
    }
    else
    {
        isLandscape=false;
        width=360;
        height=480;
    }
}

我收到屏幕在两个方向模式。我的问题是,如果我需要一个textboxField,然后在横向模式下的东西,面向肖像模式然后将数据已经一去不复返了。因为我打电话createGUI();或orientGUI();在方法的 sublayout()

这是我在触摸屏正在逐渐还有一个问题是:

One more problem that I am getting in Touch screen is:

如果我想它会打开键盘任何textboxField输入文字。这不是一个问题。最主要的是,每当键盘打开/隐藏两次再次调用这个类的 sublayout()。所以,我收到刷新屏幕。

If I want to enter text in any textboxField It opens the "keypad". Its Not a problem. The main thing is whenever the keypad open/hide both times again calling the sublayout() of that class. So I am getting the refreshed screen.

那么,有没有任何其他方法来获得方向?如果它是那么帮助我。

So, is there any other method to get Orientation? If it is then help me.

推荐答案

要解决的第一个问题,你有两个选择。

To solve the first issue, you have two options.


  • 不要删除领域,刚刚刷新屏幕的不同
    方向。


  • 保存 textboxfield 的值删除前场和
    方向改变后,使用所设置的 textboxfield 的价值
    保存的值。您将需要连得光标位置,并设置
    这点。

  • Save the value of textboxfield before you delete the field and after orientation change, set the value of textboxfield with the saved value. You will need to even get the cursor position and set that as well.

要解决的第二个问题

方向改变后,设定新的变量 currentWidth Display.getWidth()。然后,当你到通话sublayout()检查 Display.getWidth()键,看看它等于 currentWidth 。如果其等于,这意味着该方向没有改变。如果没有,那么定向发生了改变。

After orientation change, set a new variable "currentWidth" as Display.getWidth() . Then when you get a call to sublayout() check the Display.getWidth() and see if its equal to currentWidth. If its equal that means the orientation hasn't changed. If not then the orientation has changed.

希望这有助于

这篇关于更改黑莓屏幕方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆