如何为平板电脑表单布局构建CN1代码? [英] How to structure the CN1 code for a tablet form layout?

查看:43
本文介绍了如何为平板电脑表单布局构建CN1代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我一直在为电话屏幕格式构建我的Codename One应用程序.主菜单有一个单独的表单,然后是带有元素列表的第二个表单,然后是用于编辑从列表中选择的元素的第三个表单.每个表单都有一个溢出菜单和各种标题栏命令按钮.而且每个(扩展)表单都有很多代码,这些代码实现了表单中的功能并共享变量等.

I've been building my Codename One app for the phone screen format so far. There is a separate Form for the main menu, then a second Form with a list of elements, and then a third Form to edit an element selected from the list. Each Form has an overflow menu and various Titlebar command buttons. And each (Extended) Form has a lot of code that implements the functions in the Form and shares variables etc.

但是,要使用平板电脑(iPad)屏幕,我想在屏幕左侧显示主菜单,在中间显示元素列表,在右边显示元素编辑表单.与下面的屏幕截图类似.这似乎是平板电脑上的一种常见布局,非常适合我的应用使用模式.

However, to use the tablet (iPad) screen estate, I would like to show the main menu on the left of the screen, the list of elements in the middle and the element edit form on the right. Something similar to the screenshot below. This seems to be a common type of layout on tablets and suits my app usage pattern well.

但是,我没有看到一种构造代码的优雅方法.我无法轻松地将列表和表单合并到一个表单中,而仅针对平板电脑格式编写一个全新的表单将需要很多工作.我认为其他人也面临着同样的挑战,很想听听您如何做到这一点.

However, I don't see an elegant way of structuring the code to do this. I can't easily combine the list and edit Forms into one Form, and writing a completely new Form just for the tablet format would be a lot of work. I assume others have faced the same challenge and would love to hear how you achieved this.

PS.我知道可以将侧面菜单设为永久菜单,但这只能解决部分问题,而不能解决如何同时显示列表和编辑表单的问题.

PS. I know the side menu can be made permanent but that only solves part of the problem, not how to show a list and edit Forms at the same time.

推荐答案

对此没有答案,但是如果您查看

There is no one answer for this but if you look at apps like Codename One Build you would notice they adapt to this form factor.

我们通常只使用 isTablet()来使关键点的UI适应不同的尺寸.一个元素是永久性侧面菜单,我们使用如下代码打开init方法:

We usually just use isTablet() to adapt the UI at key points to the different form factor. One element is the permanent side menu which we turn on in the init method using code like this:

if(Display.getInstance().isTablet()) {
    Toolbar.setPermanentSideMenu(true);
}

它使侧面菜单始终保持打开状态.在代码中,我们尝试使用 Container 而不是 Form .这样一来,我们就可以在平板电脑模式下将多个逻辑片段打包到一个UI中.

It makes the side menu stay open all the time. Within the code we try to use Container instead of Form. This allows us to package multiple logical pieces into a single UI for the tablet mode.

这篇关于如何为平板电脑表单布局构建CN1代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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