黑莓 - 带动画的加载/等待屏幕
有没有办法在黑莓手机中显示“加载”屏幕带有动画?
选项:
- PME 动画内容
- 多线程 + 图像集 + 定时器/计数器
- 标准 rim api
- 其他方式
这是其中之一吗?
谢谢!
Is there a way to show "Loading" screen with animation in blackberry?
Options:
- PME animation content
- multithreading + set of images + timer/counter
- standard rim api
- some other way
Any of this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
费明,安东尼+1。 谢谢大家,你们给了我部分答案。
我的最终解决方案:
1.创建或生成(免费 Ajax 加载 gif 生成器)动画并将其添加到项目中。
2.创建ResponseCallback接口(参见Coderholic - Blackberry WebBitmapField)接收线程执行结果:
3.创建一个类来处理后台线程作业。 就我而言,它是http请求:
4.Create WaitScreen (全屏和 AnimatedGIFField 带有 ResponseCallback 接口):
5.最后,创建 Start 屏幕来调用 HttpConnector.HttpGetStream 并显示 WaitScreen:
更新:另一个解决方案naviina.eu:A本机 BlackBerry 应用程序中的 Web2.0/Ajax 样式加载弹出窗口
Fermin, Anthony +1. Thanks to all, you gave me the part of answer.
My final solution:
1.Create or generate (free Ajax loading gif generator) animation and add it to project.
2.Create ResponseCallback interface (see Coderholic - Blackberry WebBitmapField) to receive thread execution result:
3.Create a class to handle your background thread job. In my case it was http request:
4.Create WaitScreen (a hybrid of FullScreen and AnimatedGIFField with ResponseCallback interface):
5.In the end, create Start screen to call HttpConnector.HttpGetStream and to show WaitScreen:
UPDATE: another solution naviina.eu: A Web2.0/Ajax-style loading popup in a native BlackBerry application
这种事情的基本模式是:
让一个线程运行一个循环来更新变量(例如动画图像的帧索引),然后在绘制图像的 Field 上调用 invalidate (然后休眠一段时间)时间)。 无效将对该字段的重新绘制进行排队。
在该字段的paint方法中,读取变量并绘制图像的适当框架。
伪代码(不完全完整,但为了给您一个想法):
还要注意,这里我使用了一组位图,但 EncodedImage 允许您将动画 gif 视为一个对象,并包含获取特定帧的方法。
编辑:为了完整性:将其添加到 PopupScreen (如 Fermin 的答案)或通过直接覆盖 Screen 来创建您自己的对话框。 单独的线程是必要的,因为 RIM API 不是线程安全的:您需要在事件线程上执行与 UI 相关的所有操作(或者在持有事件锁定时,请参阅 BlackBerry UI 线程 - 基础知识
The basic pattern for this kind of thing is:
Have a thread running a loop that updates a variable (such as the frame index of the animated image) and then calls invalidate on a Field which draws the image (and then sleeps for a period of time). The invalidate will queue a repaint of the field.
In the field's paint method, read the variable and draw the appropriate frame of the image.
Pseudo code (not totally complete, but to give you the idea):
Note also here I used an array of Bitmaps, but EncodedImage lets you treat an animated gif as one object, and includes methods to get specific frames.
EDIT: For completeness: Add this to a PopupScreen (as in Fermin's answer) or create your own dialog by overriding Screen directly. The separate thread is necessary because the RIM API is not thread-safe: you need to do everything UI related on the event thread (or while holding the event lock, see BlackBerry UI Threading - The Very Basics
这是加载屏幕的简单代码......
This is simple code for loading screen ....
如果这只是一个动画,您可以显示 动画 gif 在弹出窗口上并在加载操作完成时关闭它?
If it's just an animation could you show an animated gif on a popup and close it when loading operation is complete?
最简单的方法可能是使用标准 GaugeField,设置样式 GaugeField.PERCENT。 这将为您提供一个进度条。 将其添加到 PopupScreen 中,它将位于您的内容之上。 类似......
然后有一个更新方法将使用 _gaugeField.setValue(newValue); 更新进度条。
我通常会从正在执行工作的线程调用此函数(在您的情况下加载,每次操作完成时进度条都会更新。
Easiest way is probably to use the standard GaugeField, setting style GaugeField.PERCENT. This will give you a progress bar. Add this to a PopupScreen and it will sit on top of your content. Something like..
Then have an update method which will use _gaugeField.setValue(newValue); to update the progress bar.
I normally have this called from whichever thread is doing the work (loading in your case, everytime an operation is complete the progress bar is updated.
我建议看一下这个简单的实现。 我喜欢这个,但从未使用过。 可能对你有帮助。
链接文本
I would suggest to take a look at this simple implementation. I liked this but never used it. May be helpful to you.
link text
如果您至少使用 BB OS 6.0,那么 ActivityIndicator 是一个不错的选择。
http://www.brighthub.com/mobile/blackberry-platform/articles /94258.aspx
http://docs.blackberry.com /en/developers/deliverables/17966/Screen_APIs_1245069_11.jsp
ActivityIndicator is a good option if you are working with at least BB OS 6.0.
http://www.brighthub.com/mobile/blackberry-platform/articles/94258.aspx
http://docs.blackberry.com/en/developers/deliverables/17966/Screen_APIs_1245069_11.jsp