黑莓手机 - 这是为什么BrowserField从屏幕上消失,这种变化监听后? [英] BlackBerry - Why is this BrowserField disappearing from the screen after this change listener?

查看:204
本文介绍了黑莓手机 - 这是为什么BrowserField从屏幕上消失,这种变化监听后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我坚持努力实现黑莓滑动菜单。

I'm stuck trying to implement a sliding menu in BlackBerry.

在code为幻灯片工作正常,但我不知道什么是错
与browserfield。

The code for the slide works fine, but I don't know what is wrong with the browserfield.

按按钮获得了第一次点击后,browserField从其管理器中删除,所以我想这个问题与FieldChangeListener code开头。

After the first click received by the button, the browserField is deleted from its manager, so I guess the problem starts with the FieldChangeListener code.

这是我的屏幕的全code:

This is the full code of my screen:

public final class MyScreen extends MainScreen
{
    boolean val=false;
    private BrowserField contentField;
    public MyScreen()
    {        
        final ButtonField l=new ButtonField("menu");


        final HorizontalFieldManager hfm_main=new HorizontalFieldManager();

        final VerticalFieldManager vfm_l=new VerticalFieldManager(){
             protected void sublayout(int maxWidth, int maxHeight) {
                    super.sublayout(280, maxHeight);
                    setExtent(280, maxHeight);
                }
             protected void paint(Graphics g){
                    g.setBackgroundColor(Color.RED);
                    g.clear();
                    super.paint(g);
                }
        };
        final VerticalFieldManager vfm_r=new VerticalFieldManager(){
             protected void sublayout(int maxWidth, int maxHeight) {
                 super.sublayout(maxWidth+300, maxHeight);
                 setExtent(maxWidth, maxHeight);
             }
             protected void paint(Graphics g){
                 g.setBackgroundColor(Color.YELLOW);
                 g.clear();
                 super.paint(g);
             }
        };

        vfm_l.add(new LabelField("sliding pannel"));

        vfm_r.add(l);

        BrowserField bf = new BrowserField();
        vfm_r.add(bf);
        bf.requestContent("http://www.google.com");

        hfm_main.add(vfm_r);

        add(hfm_main);

     FieldChangeListener listener=new FieldChangeListener() {

            public void fieldChanged(Field field, int context) {
                if(field==l){
                    if(!val){
                        val=true;
                        hfm_main.deleteAll();
                        hfm_main.add(vfm_l);
                        hfm_main.add(vfm_r);
                    }else{
                        val=false;
                        hfm_main.deleteAll();
                        hfm_main.add(vfm_r);

                    }
                }
            }
        };
        l.setChangeListener(listener);
    }

}

为什么browserField从屏幕上消失?

Why is the browserField disappearing from the screen?

先谢谢了。

推荐答案

我不喜欢或支持此code。如果你想拥有菜单的左边开过来的滑动,我会用屏幕转换,与左边的右边和菜单透明屏幕。可替代地,由于实际上没有滑动参与这个处理,可以显示在左手侧的弹出画面。

I don't like or support this code. If you want to have menus come sliding in from the left, I would use Screen transitions, with a 'transparent' screen on the right and menus on the left. Alternatively, since there is actually no sliding involved in this processing, you could display a popup screen on the left hand side.

但是,这code似乎使得BB尝试寻找像其他一些手机。为什么不使用所提供的BB菜单处理该用户熟悉?

But this code seems to be making the BB try to look like some other phone. Why not use the supplied BB menu processing that the users are familiar with?

最后,我怀疑这code将是一个触控板唯一设备使用的噩梦。

Finally, I suspect this code will be a nightmare to use on a trackpad only device.

下面是不是很好code,但至少它比你目前的code更好。请检查并注意修改和实施,你认为合适。

Below is not nice code, but at least it works better than your current code. Please review and note the changes and implement as you see fit.

请注意,这是可疑的:

         super.sublayout(maxWidth+300, maxHeight); // A
         setExtent(maxWidth, maxHeight); // B

你所说的每行如下
A - 你可以布局该领域采取300的像素越多,比我其实可以给这个区域,因此你可以把它300像素宽度比我实际显示结果
。B - 尽管布局占用空间,我会用我允许用于该领域的最高

What you are saying in each line is as follows A - you can layout this Field to take 300 more pixels than I can actually give to this Field, so you can make it 300 pixels wider than I can actually display.
B - despite the space that the layout takes, I will use the maximum I am allowed to for this Field.

总之,这里是我的code,似乎工作,把它作为您认为合适的,但我不支持它,并在生产计划将不会使用这样的事情....

Anyway, here is my code, it seems to work, use it as you see fit, but I don't support it and would never use anything like this in a production program....

public final class MyScreen extends MainScreen
{
    boolean val=false;
    private BrowserField contentField;
    public MyScreen() {

        final ButtonField l=new ButtonField("menu");

        final HorizontalFieldManager hfm_main=new HorizontalFieldManager();

        final VerticalFieldManager vfm_l=new VerticalFieldManager(){
             protected void sublayout(int maxWidth, int maxHeight) {
                    super.sublayout(280, maxHeight);
                    setExtent(280, maxHeight);
                }
             protected void paint(Graphics g){
                    g.setBackgroundColor(Color.RED);
                    g.clear();
                    super.paint(g);
                }
        };
        final VerticalFieldManager vfm_r=new VerticalFieldManager(){
             protected void sublayout(int maxWidth, int maxHeight) {
                 int ourRequiredWidth = Display.getWidth();
                 super.sublayout(ourRequiredWidth, maxHeight);
                 setExtent(ourRequiredWidth, maxHeight);
             }
             protected void paint(Graphics g){
                 g.setBackgroundColor(Color.YELLOW);
                 g.clear();
                 super.paint(g);
             }
        };

        vfm_l.add(new LabelField("sliding pannel"));

        vfm_r.add(l);

        BrowserField bf = new BrowserField();
        vfm_r.add(bf);
        bf.requestContent("http://www.google.com");

        hfm_main.add(vfm_r);

        add(hfm_main);

        FieldChangeListener listener=new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
                if(field==l){
                    if(vfm_l.getManager() == null){
                        hfm_main.insert(vfm_l, 0);
                    } else {
                        hfm_main.delete(vfm_l);
                    }
                }
            }
        };

        l.setChangeListener(listener);
    }

}

这篇关于黑莓手机 - 这是为什么BrowserField从屏幕上消失,这种变化监听后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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