Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 从按下的BlackBerry屏幕返回到父屏幕_User Interface_Blackberry_Java Me_Mobile - Fatal编程技术网

User interface 从按下的BlackBerry屏幕返回到父屏幕

User interface 从按下的BlackBerry屏幕返回到父屏幕,user-interface,blackberry,java-me,mobile,User Interface,Blackberry,Java Me,Mobile,我有一个黑莓应用程序的主菜单。当我输入菜单项并需要返回主菜单时,我想访问不同的屏幕。我怎么做 以下是我尝试过但按下“后退”按钮时遇到的运行时异常: package com.stockmarket1; import net.rim.device.api.system.Bitmap; import net.rim.device.api.ui.*; import net.rim.device.api.ui.container.*; import net.rim.device.api.u

我有一个黑莓应用程序的主菜单。当我输入菜单项并需要返回主菜单时,我想访问不同的屏幕。我怎么做

以下是我尝试过但按下“后退”按钮时遇到的运行时异常:

package com.stockmarket1;


import net.rim.device.api.system.Bitmap;
  import net.rim.device.api.ui.*;
  import net.rim.device.api.ui.container.*;
  import net.rim.device.api.ui.component.*;
  import net.rim.device.api.ui.decor.*;
  import net.rim.blackberry.api.push.PushApplication;

    public class StockMarket extends UiApplication implements FieldChangeListener   {
      public Screen _clientList;
      public Screen _comments;
      public Runnable _popRunnable;

    public static void main(String[] args)
    {
        StockMarket theApp = new StockMarket();
        theApp.enterEventDispatcher();
    }

    public StockMarket() {
        //Code for MainScreen
        final MainScreen baseScreen = new MainScreen();

        baseScreen.setTitle("Colombo Stock Exchange");
        ButtonField clientList = new ButtonField("View Client List", ButtonField.CONSUME_CLICK);
        clientList.setChangeListener(new FieldChangeListener() {

            public void fieldChanged(Field field, int context) {
                pushScreen(_clientList);
                }
        });

        ButtonField comments= new ButtonField("View Comments", ButtonField.CONSUME_CLICK);
        comments.setChangeListener(new FieldChangeListener() {

            public void fieldChanged(Field field, int context) {
                pushScreen(_comments);
                }
        });     
        Bitmap bitmap = Bitmap.getBitmapResource("logo1.png");
        BitmapField logo = new BitmapField(bitmap, BitmapField.FIELD_HCENTER);
        LabelField newLine = new LabelField("\n");

        baseScreen.add(logo);
        baseScreen.add(newLine);
        baseScreen.add(clientList);
        baseScreen.add(comments);


        //Code for _comments
        _comments = new FullScreen();
        _comments.setBackground(BackgroundFactory.createSolidBackground(Color.LIGHTCYAN));
        LabelField title = new LabelField("Comments",LabelField.FIELD_HCENTER);


        LabelField comment = new LabelField("Type");
        RichTextField rtfComment = new RichTextField();

        _comments.add(title);
        _comments.add(comment);
        _comments.add(rtfComment);

        //Code for _clientList
        _clientList = new FullScreen();
        _clientList.setBackground(BackgroundFactory.createSolidBackground(Color.LIGHTBLUE));
        LabelField clientTitle = new LabelField("Listed Companies\n\n", LabelField.FIELD_HCENTER);
        LabelField line = new LabelField("__", LabelField.USE_ALL_HEIGHT);

        ButtonField closeClient = new ButtonField("Close", ButtonField.CONSUME_CLICK);


        closeClient.setChangeListener(new FieldChangeListener() {

            public void fieldChanged(Field field, int context) {
                pushScreen(baseScreen);
            }
        });

        _clientList.add(clientTitle);
        _clientList.add(line);

        //Events
        pushScreen(baseScreen);
    }

    public void fieldChanged(Field field, int context) {
        // TODO Auto-generated method stub

    }
}

“关闭”按钮的代码是一个问题,但我想你说过当按下设备上的“后退”按钮时会出现运行时异常,我认为这是另一个原因

不要将菜单屏幕推到屏幕堆栈上,只需弹出当前屏幕即可。这将返回到以前显示的菜单屏幕:

    closeClient.setChangeListener(new FieldChangeListener() {
        public void fieldChanged(Field field, int context) {
            // previous code:
            // pushScreen(baseScreen);
            // correct code:
            popScreen(_clientList);
        }
    });