ButtonGroup 和资源编辑器

发布于 2024-11-26 05:43:01 字数 282 浏览 1 评论 0原文

我们正在尝试尽可能多地使用 LWUIT 资源编辑器创建应用程序,也就是说,如果可以的话,避免通过代码创建 UI。

我们发现可以通过在资源编辑器工具上设置相应的属性来将组分配给 RadioButton

因此,当我们需要为这些单选按钮实现一些功能时,我们如何获取对 UIBuilder 创建的 ButtonGroup 实例的引用(我想)?

是的,考虑到我们使用资源编辑器工具来生成 midlet,“自定义”代码是在 StateMachine 类上编写的。

问候。

We are trying to create an application using the LWUIT Resource Editor as much as possible, it's to say, avoiding creating the UI by code if we can.

We found out there is the possibility to assign a group to a RadioButton by setting the corresponding property on the Resource Editor tool.

So, as we need to implement some functionality for those radio buttons, how can we get the reference to that ButtonGroup instance that the UIBuilder has created (I suppose)?

And yes, considering we are using the Resource Editor tool to generate our midlets, the "custom" code is written on the StateMachine class.

Regards.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

铁憨憨 2024-12-03 05:43:01

AFAIK 您无法从 ResourceEdit#GUI 获取 ButtonGroup 。您只能获取 RadioButton 组名称。但可以通过代码将 RadioButton 添加到 ButtonGroup 中。请参阅以下代码,

用于调用 StateMachine() 构造函数(在构造函数内部使用此代码),

Form form = (Form) this.startApp(resources, null, true);
 RadioButton rb1 = this.findRadioButton(form);
 RadioButton rb = this.findRadioButton1(form);
 ButtonGroup bg = new ButtonGroup();
 bg.add(rb);
 bg.add(rb1);
 bg.setSelected(0);

用于调用 StateMachine(String resFile) 构造函数(在 MIDlet 内部使用此代码)班级),

 StateMachine sm = new StateMachine("/Sample.res");
 RadioButton rb1 = sm.findRadioButton(Display.getInstance().getCurrent());
 RadioButton rb = sm.findRadioButton1(Display.getInstance().getCurrent());
 ButtonGroup bg = new ButtonGroup();
 bg.add(rb);
 bg.add(rb1);
 bg.setSelected(0);

AFAIK you can't get ButtonGroup from ResourceEdit#GUI. You can only possible to get RadioButton group name. But possible to add the RadioButton into ButtonGroup through your code. See the following code,

For calling StateMachine() constructor(use this code inside of constructor),

Form form = (Form) this.startApp(resources, null, true);
 RadioButton rb1 = this.findRadioButton(form);
 RadioButton rb = this.findRadioButton1(form);
 ButtonGroup bg = new ButtonGroup();
 bg.add(rb);
 bg.add(rb1);
 bg.setSelected(0);

For calling StateMachine(String resFile) constructor(use this code inside of your MIDlet class),

 StateMachine sm = new StateMachine("/Sample.res");
 RadioButton rb1 = sm.findRadioButton(Display.getInstance().getCurrent());
 RadioButton rb = sm.findRadioButton1(Display.getInstance().getCurrent());
 ButtonGroup bg = new ButtonGroup();
 bg.add(rb);
 bg.add(rb1);
 bg.setSelected(0);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文