如何处理 J2ME GUI 应用程序中的按键操作
我使用 javax.microedition.lcdui.*(Gauge、List、ChoiseGroup)GUI 元素在 J2ME 中为手机编写了蓝牙电视遥控器。
我希望手机与我的电视进行实时交互,我想找到一种方法将使用 GUI 元素执行的用户输入立即发送到电视(例如更改频道或更改音量)。
由于我希望与电视进行实时交互,因此我想找到一种方法将使用 GUI 元素执行的用户输入立即发送到电视(例如更改频道或更改音量)。
使用javax.microedition.lcdui.Command
/ CommandListner
和commandAction
将不起作用,因为它们只需要识别使用侧面按钮选择的命令。 我想要一个可以识别按下的任何键的东西。
我发现 Javax.microedition.lcdui.Canvas.keyPressed 可以处理手机上按下的任何按键,但我不知道如何使 Canvas 与 Gauge 等 MIDP GUI 元素一起使用。 它们不能像命令一样添加。
我是否必须找到为这些 GUI 元素构建界面以使它们与 Canvas 一起使用的方法?
I programmed a bluetooth Television-Remote control for cellphones in J2ME using javax.microedition.lcdui.*
(Gauge, List, ChoiseGroup) GUI-Elements.
I want the cellphone to have real-time interaction with my Television, I would like to find way to send user inputs performed with the GUI-Elements immediately (like changing the channel, or changing the volume) to the Television.
Since I want real-time interaction with my Television, I would like to find way to send user inputs performed with the GUI-Elements immediately (e.g. changing the channel, or changing the volume) to the TV.
Using javax.microedition.lcdui.Command
/ CommandListner
and commandAction
won't work since these need only recognize the commands selected with the side buttons. I would like to have something that can recognize any key pressed.
I discovered that Javax.microedition.lcdui.Canvas.keyPressed
can handle any key pressed on the cellphone, but I don't know how to make Canvas work with MIDP GUI elements like Gauge. They can't be added like Commands.
Do I have to figure out way to build a interface for these GUI elements to make them work with Canvas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我自己刚刚找到了一半的解决方案,如果有人感兴趣的话:
“javax.microedition.lcdui.ItemStateListener”。
该函数可以实时处理GUI项的状态(或状态变化)。
它不是按键,但这对我的应用程序也适用。
I just found a half solution myself, if anyone is interested:
"javax.microedition.lcdui.ItemStateListener".
This function can handle the states (or state changes) of the GUI items in realtime.
Its not keyPress, but this will work as well for my application.
根据此常见问题解答,您不能做你所要求的。 这是关于 MIDP 1.0 的,但我相信它也适用于 MIDP 2.0。 如果您只需要一个仪表,您可以轻松地自己绘制。
According to this FAQ you can't do what you are asking for. This is about MIDP 1.0, but I believe it also applies for MIDP 2.0. If it is only a gauge you need, you can easily paint it yourself.
据我所知,这只能使用 画布。
From what I saw this can only be done using a Canvas.
我强烈建议您在 Canvas 对象上绘制类似 Gauge 的项目,或者遵循“zhengtonic”于 12 月 19 日 15:00 给出的建议。
我不知道解决这个问题的任何其他方法,我曾经在那里,但使用了我提供的第一个选项
I will strongly recommend that you should either draw your Gauge-like item on a Canvas object or you follow the advice given on Dec 19 at 15:00 by "zhengtonic".
I dont know any other approach to this problem, I was once there but used the first options provided by me