Java 黑莓位图单击

发布于 2024-12-29 05:33:22 字数 848 浏览 1 评论 0原文

我感兴趣的是有一个位图图标,单击该图标将打开一个新屏幕。现在到目前为止,我一直在使用此链接来实现绘制位图:

Blackberry Clickable BitmapField

这段代码的意思是在屏幕上绘制位图并在单击时引发操作。它有两张带焦点和不带焦点的图片。我用以下方式调用它:

CustomMenuButtonField buttonInstance = new CustomMenuButtonField("img1.png", "img2.png");
add(buttonInstance);

我已经更改:

protected boolean navigationClick(int status, int time)
    {
        Alert.startVibrate(50);
        //fieldChangeNotify(0);
        return true;
    }

我遇到的一个问题是,当我单击字段管理器中的图像外部时,图片仍然会更改并且会引发一个操作(振动)。从这里开始,它一直处于“焦点”状态,直到我单击窗口上的另一个文本字段,但单击空白区域仍然不会改变它。我的问题是这种情况是否会发生,是否有办法限制它,以便仅当您单击位图而不是在它周围时才会引发该操作?还有一种简单的方法可以将位图缩放为更小的尺寸(例如图标)吗?我试图放置 4 个图标,单击这些图标将打开四个不同的屏幕。如果有人知道这方面的任何信息,我们将不胜感激。我刚刚开始学习 Java,所以我是一个极端的新手。

I am interested in having a bitmap icon that when clicked will open a new screen. Now so far I have been using this link to achieve drawing the bitmap:

Blackberry Clickable BitmapField

This code is meant to draw a bitmap on the screen and evoke an action when clicked upon. It has two pictures with and without focus. I am calling it with:

CustomMenuButtonField buttonInstance = new CustomMenuButtonField("img1.png", "img2.png");
add(buttonInstance);

I have changed:

protected boolean navigationClick(int status, int time)
    {
        Alert.startVibrate(50);
        //fieldChangeNotify(0);
        return true;
    }

One issue I am having is that when I click outside the image in the field manager, the picture is still changed and an action is evoked (vibrates). From here it stays in the "focus" until I click on another text field on the window, but clicking on white space still does not change it. My question is should this be happening, and is there a way to limit it so the action is evoked JUST when you click the bitmap and not around it? Also is there a simple way to scale the bitmap into something of smaller size such as an icon? I am trying to position 4 icons that when clicked will open four different screens. If anyone knows anything about this any assistance would be appreciated. I just started Java so I'm an extreme novice.

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

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

发布评论

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

评论(1

独行侠 2025-01-05 05:33:22

注意:我对 Blackberry API 抱有很大偏见。

我已经很长时间没有在 Blackberry(版本 5)软件上做过任何工作了,所以我的建议可能是完全过时了。 (我想我正在工作版本5)。

提供的组件完全不足以满足我们需要执行的任何具有自定义外观和感觉的操作,因此我们采用重写 Manager 类来创建自定义组件的方法。

//Garbage code from a dead project
      /* (non-Javadoc)
       * @see net.rim.device.api.ui.Manager#paint(net.rim.device.api.ui.Graphics)
       */
      protected void paint(Graphics graphics) {
        if(style == Spinner.DRAW_ROUNDED_RECTANGLE)
          drawRoundedRectangluar(graphics);
        else
          drawRectangular(graphics);
      }

其余的都是垃圾,所以我只发布它的想法

如果你扩展一个可以工作的按钮并替换绘制方法(与使用 Swing 不同,除了无限更痛苦)你基本上可以做你想做的事。这将使您能够缩放图像并执行您需要的任何操作。

不过,我希望黑莓在过去几年中更新了他们的 API。这个项目很痛苦,并且花费了大约 10 倍的工作量来完成您认为应该花费的工作量。

另外,事件需要(编辑?)在设备上使用,否则它们会自动传播(在侦听器上返回 true 表示事件已使用。)

如果不知道版本和确切的 API,恐怕我无法除了说我强烈建议坚持绝对最低要求之外,还有更多帮助,以便它可以移植到所有设备或尝试通过移动网络界面(并不总是一个选项)来完成应用程序。我发现黑莓在我的开发过程中陷入了泥潭,所以我放弃了它。

在使用它时,我发现从头开始编写绘画比尝试使它们的组件一致工作要快,这是可行的,并且 95% 的摆动教程将无需额外工作即可翻译。

(另外,SWT 更适合 API,您应该在 Eclipse 上检查一下——如果您没有使用 Eclipse 进行 Blackberry 开发,请在使用时选择它。RIM 工具来自盒子太可怕了。)

Note: I'm highly biased against the Blackberry API.

It has been a long time since I did any work on the Blackberry (version 5) software so my advice might be totally out of date. (I think I was working version 5).

The components provided were totally inadequate for anything we needed to do that had a custom look and feel so we took the approach of overriding the Manager class to create custom components.

//Garbage code from a dead project
      /* (non-Javadoc)
       * @see net.rim.device.api.ui.Manager#paint(net.rim.device.api.ui.Graphics)
       */
      protected void paint(Graphics graphics) {
        if(style == Spinner.DRAW_ROUNDED_RECTANGLE)
          drawRoundedRectangluar(graphics);
        else
          drawRectangular(graphics);
      }

The rest of this is garbage so I'm only posting the idea of it

If you extend a button that works and replace the paint method (not unlike working with Swing, except infinitely more painful) you can basically do whatever you want. This would give you the ability to scale the image and do whatever you need.

However, I hope Blackberry has updated their API in the last few years. This project was painful and took about ~ 10 times the amount of work it should have to accomplish what you thought it should take.

Also, events need(ed?) to be consumed on the device otherwise they would automatically propagate (return true on the listeners to indicate the event is consumed.)

Without knowing the version and the exact API I'm afraid I can't be of more help other than saying I would highly recommend sticking with the absolute minimum requirements so it ports to all the devices OR try to accomplish the application through a mobile web interface (not always an option). I found the Blackberry to be a quagmire in my development time and I abandoned it.

When working with it I found writing the painting from scratch was faster than trying to make their components work consistently, its doable, and 95% of the swing tutorials will translate with very little additional work.

(Also, SWT is a little better fit for the API, you should check that out over at Eclipse--and if you're not using Eclipse for Blackberry development pick that up while you're at it. The RIM tools out of the box were horrible.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文