如何在应用程序的主屏幕中显示屏幕

发布于 2025-01-02 19:20:13 字数 898 浏览 5 评论 0原文

我的应用程序的详细信息下方有一个屏幕。屏幕名称 EventList 。这个屏幕设计的很饱满。有两个 ButtonField NextPrevious 。在这两个Button的底部,ListField被放置在这个屏幕中。

当我点击 NextPrevious 时,我的 ListField 将更新。使用在此屏幕中创建的 updateListField() 方法 成功更新它。到目前为止一切都运转良好。但我担心的是,当我单击这些 Button ListField 时,将需要时间(大约 3 或 4 秒)来更新新数据。在后台更新数据期间,我想显示 Massage,例如 请稍候.../正在加载...。我如何在不使用 PopupScreen 的情况下显示此内容。

我尝试过下面的代码,但无法正常工作。

VerticalFieldManager manager = new VerticalFieldManager();

manager.add(new LabelField("Please Wait..."));
Screen popup = new PopupScreen(manager);

如果我使用 PopupScreen 来完成此操作,则该屏幕的完整逻辑将发生变化,这将是一项耗时的任务。

请建议我如何在现有的 MainScreen 上添加 FieldManager

提前致谢 !!!

My application have one screen below the detail of that. Screen name EventList . This screen have designed full. There are two ButtonField Next and Previous . At the bottom of these two Button ListField is placed in this screen.

When i click on Next or Previous my ListField will update . It is updated successfully using updateListField() method which is created in this screen. All is working fine up to this. But my concern is that when i click on these Button ListField will take time (around 3 or 4 second)to update new data. During my data updating in background i want to show Massage like Please wait.../Loading.... How can i show this without using PopupScreen.

i had tried the below code but not working properly.

VerticalFieldManager manager = new VerticalFieldManager();

manager.add(new LabelField("Please Wait..."));
Screen popup = new PopupScreen(manager);

If i will done this using PopupScreen my full logic will be change for that screen and it will time consuming task.

Please suggest me how can we add FieldManager on existing MainScreen.

Thanks in Advance !!!

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

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

发布评论

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

评论(2

你是年少的欢喜 2025-01-09 19:20:13

MainScreen 类包含一个可用于此目的的状态字段。在扩展 MainScreen 的类中添加:

setStatus(new LabelField("Please wait..."));

以删除该状态:

setStatus(null);

但是,您需要在事件线程上执行此操作,然后返回,以便操作系统可以更新用户界面。如果您在事件线程(按下按钮时将调用您的代码的线程)上执行列表更新,那么您应该在单独的线程上执行该工作并使用 UiApplication.invokeLater() 或持有事件锁在用户界面上执行更新。

The MainScreen class includes a status field that you can use for this. In your class extending MainScreen add:

setStatus(new LabelField("Please wait..."));

to remove that status:

setStatus(null);

However, you need to do this on the event thread and then return so the OS can update the user interface. If you are performing the update of your list on the event thread (the thread that will call your code when the button is pressed) then you should perform that work on a spearate thread and use UiApplication.invokeLater() or hold the event lock to perform updates on the user interface.

梦巷 2025-01-09 19:20:13
Application.getApplication().invokeLater( 
new Runnable() { 
public void run() { 

GIFEncodedImage image; 
EncodedImage encodedImage = EncodedImage 
.getEncodedImageResource("spiral.gif"); 
byte data[] = new byte[3000]; 
data = encodedImage.getData(); 
image = (GIFEncodedImage) EncodedImage 
.createEncodedImage( 
data, 0, 
data.length); 
AnimatedGIFField animatedGIF = new AnimatedGIFField( 
image); 

PopupScreen popup = new PopupScreen( 
new VerticalFieldManager()); 
popup.add(animatedGIF); 
Border border = BorderFactory 
.createSimpleBorder( 
new XYEdges(), 
Border.STYLE_SOLID); 
popup.setBorder(border); 
UiApplication 
.getUiApplication() 
.pushScreen(popup); 

Timer timer = new Timer(); 
timer.schedule(new CountDown(), 
3000); 

} 
});
Application.getApplication().invokeLater( 
new Runnable() { 
public void run() { 

GIFEncodedImage image; 
EncodedImage encodedImage = EncodedImage 
.getEncodedImageResource("spiral.gif"); 
byte data[] = new byte[3000]; 
data = encodedImage.getData(); 
image = (GIFEncodedImage) EncodedImage 
.createEncodedImage( 
data, 0, 
data.length); 
AnimatedGIFField animatedGIF = new AnimatedGIFField( 
image); 

PopupScreen popup = new PopupScreen( 
new VerticalFieldManager()); 
popup.add(animatedGIF); 
Border border = BorderFactory 
.createSimpleBorder( 
new XYEdges(), 
Border.STYLE_SOLID); 
popup.setBorder(border); 
UiApplication 
.getUiApplication() 
.pushScreen(popup); 

Timer timer = new Timer(); 
timer.schedule(new CountDown(), 
3000); 

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