怎样才能“戳”到?一个遵循观察者模式的 Android 应用程序?
我有一个小型 Android 应用程序,它实现了 观察者模式。
我想要我的“主题”(或被观察的事物)来更改其状态,例如将其字符串从 hello
更改为 hello world
。
我怎样才能通过模拟器做到这一点?
我需要我的(观察)android 应用程序仍然在前台运行,以便它可以显示正在观察的任何内容,但我需要找到某种方法来改变观察对象的状态,是否可以通过命令行来做到这一点?我还能如何“戳”观察到的对象来改变其状态。
我能想到的一种脏黑客方法是在循环中设置观察到的对象,因此每 10 秒它就会更改其状态,但这并不好,因为那样我将无法控制它。
I've got a small android application that implements the Observer pattern.
I want my "subject" (or the thing being observed) to change its state, such as changing its String from hello
to hello world
.
How can I do this via the emulator?
I need my (observing) android application to still run in the foreground so it can display whatever is being observed, but I need to find some way to alter the state of the observed object, is it possible to do this via the command line? How else can I "poke" the observed object to change its state.
One dirty-hack method I can think of is to set the observed object up in a loop, so every 10 seconds it changes its state, but that is not good as then I won't have control over it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正确答案:编写一个测试用例,并让测试用例“戳”观察到的对象。
不太正确的答案:向您的活动中添加一些内容以“戳”观察到的对象。
Correct answer: write a test case, and have the test case "poke" the observed object.
Not-quite-as-correct answer: add stuff to your activity to "poke" the observed object.