如何使用屏幕对象访问屏幕上的文件(UiApplication.getUiApplication().getActiveScreen())
我的问题是如何使用屏幕对象访问堆叠屏幕上的字段?
确切的问题如下:
我有一个屏幕,其中有一个文本字段(ClientName),当用户单击该字段时,应用程序将推送一个新屏幕,并允许用户使用 MyWebSerivces 在远程数据库中进行搜索。当用户从搜索结果中选择一个客户端时,我想使用用户在当前屏幕上选择的文本设置前一个屏幕上的文本字段。
我尝试过 PushScreen( new screen("text) ) 和如果我只想执行一次此操作,这可能是结果,但这不是我的选择,因为还有两个这样的字段将转到其他屏幕以从网络服务获取数据,并且如果我每次推送新的数据。然后在每次推屏操作后我只会得到一个包含所需文本的字段
My Query is How to access Fields on the stacked screen using Screen Object ?
The exact problem is as follows:
I have one screen which has one text field (ClientName) when user clicks on that field , application will then push a new screen and it will allow the user to search in remote database using MyWebSerivces. and when user selects the one client from the search result ,i want to set the text Field on the previous screen with the text that user has selected on the current screen..
i have tried the pushScreen( new screen("text) ) and that might be the result if i want to do this operation only once but this is not the option for me since there is two more such field which will go to other screen to fetch the data from webservices . and if i every time i push new screen then after every pushscreen operation i will only get one field set with the desired text
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这不是黑莓(或任何特定编程语言)相关的问题。这是一个应用程序架构和常识的问题。如果一个屏幕应更改另一个屏幕的
Field
,则只需将Field
的引用传递到将更改它的屏幕即可。This not a blackberry (or any specific programming language) related question. This is a question of application architecture and common sense. If one screen should change a
Field
of another screen, then just pass a reference of theField
to the screen that will change it.嗨,我曾经遇到过同样的问题,我是这样的:
Screen1
当用户单击此文本字段或您按 Screen2 的任何按钮时
在屏幕 2 中,当用户选择特定值时,您将执行此操作。
1)在主类中使用一个静态变量,例如clientName。
2) 设置该变量的值。
3) 调用此代码时弹出活动屏幕
然后返回到 Screen1
现在在 screen1 中调用一个方法
hi i once had same problem and i did like this:
Screen1
When user clicks on this text field or any button you push Screen2
In screen 2 when user selects a particular value then u do this.
1) take a static variable in main class say clientName.
2) set value of this variable.
3) pop active screen
when this code is called then u come back to Screen1
Now in screen1 a method is called
我已经找到了我的问题的答案。解决方案就在我的问题中,但一开始我找不到它。
解决方案很简单
当我写作时,我想使用
这几乎是正确的方式,并且我正在朝着正确的方向前进,但我缺少的是“我没有将屏幕(我刚刚从堆栈顶部检索)投射到其类型
我唯一应该做的就是“应该将屏幕投射为其类型。像这样,
现在我可以访问检索到的屏幕(MyScreen1)上的所有字段
,要记住的事情是
在堆栈上使用屏幕的好处
i have found the answer to my question. the solution was there lying in my question but at first i was not able to find it.
solution was very simple
when i wrote i want to use
that was almost the right way and i was proceeding in right direction but the thing that i was missing was " I was not casting the screen (that i have just retrieved form the stack top ) to its type
only thing i should have done is "should have casted screen to its type.like this
now i am able to access all the fields on the retrieved screen (MyScreen1)
things to keep in mind
Benifits of using screen on Stack