0

我正在创建一个 BlackBerry 应用程序,现在我想在单击图像按钮时呈现动画。在我的应用程序中,我使用启动画面,然后显示登录页面。当我点击我的登录页面的提交按钮时,会显示一个主屏幕,我想在那里显示一个幻灯片动画。

这是我的代码:

public class LoginPage extends MainScreen implements FieldChangeListener {

      public TextField tf_username;
      public TextField tf_password;     
      private Bitmap[] img1;    
      public LabelField labeluser;  
      public LabelField labelpass;  
      public static String strUsername = "";    
      public static String strPassword = "";    
      public CheckboxField objRemembercheckbox;     
      private ImageButton btn_login;    
      private ImageButton btn_clear;    
      public BitmapField loading = new BitmapField(Bitmap.getBitmapResource("login-bar.png"));
      public H_FieldManager hfm_btn;
      public VerticalFieldManager vfm_user, vfm_pass; 
      public PleaseWaitPopupScreen waitPopupScreen = null;  
      public VerticalFieldManager vfmMainManager;   
      public static boolean loginFlag = false; 
      public static boolean flagOutletButton;
      public RecordStore objLoginRecordStore;
      private String login_record_Store_Name = "LoginRMS";

    public LoginPage() {        // TODO Auto-generated constructor stub         super(USE_ALL_WIDTH | USE_ALL_HEIGHT);      setTitle(loading);
                try {
                        Background bg = BackgroundFactory.createSolidTransparentBackground(
                    Color.BLUE, 100);           getMainManager().setBackground(bg);
                    } catch (Exception e) {             // TODO: handle exception       }

        labeluser = new LabelField("Enter Username : ", Field.FIELD_LEFT);      labeluser.setMargin(10, 0, 0, 10);      labeluser.setColor(Color.BLACK);

        tf_username = new TextField(TextField.TYPE_PLAIN, Field.FIELD_HCENTER);

        labelpass = new LabelField("Enter Password : ", Field.FIELD_LEFT);      labelpass.setMargin(10, 0, 0, 10);      labelpass.setColor(Color.BLACK);

        tf_password = new TextField(TextField.TYPE_PASSWORD,
                Field.FIELD_HCENTER);

        objRemembercheckbox = new CheckboxField("Remember Me", false);      objRemembercheckbox.setMargin(10, 0, 0, 10);

                img1 = new Bitmap[3];       img1[0] = Bitmap.getBitmapResource("btn-hover.png");        img1[1] = Bitmap.getBitmapResource("btn.png");      img1[2] = Bitmap.getBitmapResource("btn.png");

        btn_login = new ImageButton(img1, "Login", Field.FIELD_LEFT);       btn_login.setColor(Color.WHITE);        btn_clear = new ImageButton(img1, "Clear", Field.FIELD_RIGHT);      btn_clear.setColor(Color.WHITE);

        hfm_btn = new H_FieldManager(btn_login, btn_clear, true,
                Field.FIELD_HCENTER);       vfm_user = new VerticalFieldManager();      vfm_user.add(labeluser);        vfm_user.add(tf_username);

        vfm_pass = new VerticalFieldManager();      vfm_pass.add(labelpass);        vfm_pass.add(tf_password);      add(vfm_user);      add(vfm_pass);      add(objRemembercheckbox);       add(hfm_btn);

        btn_login.setChangeListener(this);      btn_clear.setChangeListener(this);

    }

    public void fieldChanged(Field field, int context) {        // TODO Auto-generated method stub      if (field == btn_clear) {           tf_username.setText(" ");           tf_password.setText(" ");

        } else if (field == btn_login) {            login();        }

    }


public void login() {

        try {

            LoginPage.strUsername = tf_username.getText().toString();           System.out.println("strUsername==" + strUsername);          LoginPage.strPassword = tf_password.getText().toString();           System.out.println("strPassword==" + strPassword);

            if (strUsername.length() == 0 || strPassword.length() == 0
                    || strUsername == null || strPassword == null) {
                Dialog.alert("You must enter credentials");
                invalidate();           } else {

                // strUsername=username.getText();
                // strPassword=password.getText();

                try {

                    waitPopupScreen = new PleaseWaitPopupScreen("Please wait..");
                    UiApplication.getUiApplication()
                            .pushScreen(waitPopupScreen);
                    new Thread() {
                        public void run() {
                            ConnectToServer objConnectToServer = new ConnectToServer();


                            loginFlag = objConnectToServer.loginCheck(
                                    strUsername, strPassword);

                            UiApplication.getUiApplication().invokeLater(
                                    new Runnable() {
                                        public void run() {
                                            UiApplication.getUiApplication()
                                                    .popScreen(waitPopupScreen);

                                            if (loginFlag == true) {
                                                LoginPage.flagOutletButton = false;
                                                System.out
                                                        .println("Calling getOutletInfo");

                                                HomeScreen objHome= new HomeScreen ();
                                                UiApplication
                                                        .getUiApplication()
                                                        .pushScreen(objHome);

                                            }

                                            else {
                                                Dialog.alert("Username Or Password Is Incorrect");

                                            }

                                        }

                                    });
                        };
                    }.start();

                    // ConnectToServer objConnectToServer=new ConnectToServer();
                    //
                    // loginFlag=objConnectToServer.loginCheck(strUsername,
                    // strPassword);

                    System.out.println("loginFlag==" + loginFlag);

                } catch (Exception e) {
                    // TODO: handle exception
                    e.printStackTrace();
                }

            }

        } catch (Exception e) {             // TODO: handle exception           e.printStackTrace();        }

    }

  }

请建议如何实现幻灯片动画。

谢谢你。

4

1 回答 1

3

尝试以下链接:

TransitionContext - TransitionContext 类包含唯一描述两个屏幕之间的过渡动​​画所需的所有数据。

黑莓屏幕转换示例代码

BlackBerry Java 应用程序屏幕转换 - 示例应用程序概述

创建屏幕转换代码示例

于 2012-07-05T07:48:30.447 回答