Codenameone表单添加了另一个标题,而不是在添加工具栏时进行更新 [英] Codenameone Form adds another title instead of updating when Toolbar added

查看:55
本文介绍了Codenameone表单添加了另一个标题,而不是在添加工具栏时进行更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Codenameone应用程序中向我的表单添加工具栏时,我遇到了一个奇怪的问题。如果我在表单上设置了一个工具栏,它将显示另一个标题,其中包含工具栏汉堡包和新标题,位于前一个表单的标题下方,而不是像我期望的那样替换它。看起来像这样:

I'm running into a strange issue when adding a Toolbar to my Form in my Codenameone app. If I set a toolbar on my form, it shows another title with the toolbar hamburger and new title below the title of the previous form instead of replacing it like I would expect. It looks like this:

该功能可以很好地替换旧标题,就像我在我期望的那样可以在Codenameone模拟器中运行,但是在进行Android构建并在Nexus 5(6.0.1)上运行该图像时,出现了这种奇怪的行为。后退箭头和 12之12是previousForm的标题

The functionality works fine replacing the old title like I would expect when I run in the Codenameone simulator, but I get this weird behavior shown in the image when I make an Android build and run it on a Nexus 5 (6.0.1). The back arrow and "12 of 12" is the title from the previousForm

这是我的代码,我在此处对工具栏的使用有误吗?

This is my code, am I doing anything wrong here with the Toolbar usage?

    void goShowResource(final Form previousForm) {
    previous = previousForm;
    final Toolbar bar = new Toolbar();
    final Form rd = new Form("resource details");
    final Resource thisResource = this;

    rd.setToolbar(bar);

    bar.addCommandToSideMenu(new Command("command 1") {
        @Override
        public void actionPerformed(ActionEvent evt) {
            AddResources ar = new AddResources(settings, thisResource);
            ar.goAddResources(rd);
        }
    });

    bar.addCommandToSideMenu(new Command("command 2") {
        @Override
        public void actionPerformed(ActionEvent evt){
            UpdateResource ur = new UpdateResource(settings);
            ur.goUpdateResource(rd, thisResource);
        }
    });

    rd.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    showDetails(rd);
    rd.show();
}

编辑:附加信息,如果我一次打开侧面菜单,则旧标题栏在顶部缩小,然后剩下一个正确但格式错误的标题区域。

edit: Additonal info, if I open the sidemenu once, the old title bar at the top shrinks away, and I'm left with the the single correct yet incorrectly formatted title area.

推荐答案

您应该使用应用程序中所有表单的工具栏,或在使用工具栏时禁用默认值即本机菜单栏。您可以通过编辑主题并选择常量选项卡,然后按添加并选择 commandBehavior = Side 来完成后者。

You should use the Toolbar for all the forms in the app or disable the default which is native menu bar when working with the toolbar. You can do the latter by editing the theme and selecting the constants tab then pressing "Add" and selecting commandBehavior=Side.

Android当前默认为原生的 ActionBar 行为,而 Toolbar 会隐式覆盖此行为,但是当从

Android currently defaults to the native ActionBar behavior and Toolbar implicitly overrides that, however when a transition occurs from the native to the lightweight component things can get pretty hairy (and might also look unnatural) so we recommend picking one UI paradigm and going with it.

自<$ c $起,我们建议选择一种UI范式并进行处理。

Since the ActionBar is a volatile API we recommend Toolbar going forward as its far more customizable and gives us a lot of control.

这篇关于Codenameone表单添加了另一个标题,而不是在添加工具栏时进行更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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