且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在没有Activity的情况下,如何在Android JUnit测试中的UI线程中运行代码?

更新时间:2022-11-03 14:52:15

Android.OS.Handler应该能够更新ui.

Android.OS.Handler should be able to update the ui.

要使用处理程序,您必须将其子类化并覆盖handleMessage()来处理消息

To use a handler you have to subclass it and overide handleMessage() to process messages

更新:

我使用的是Monodroid,所以我不知道这是否完全可翻译,但是,

I am using monodroid, so I dont know if this is completely translatable, But,

您也许可以使用

new Handler(context.getMainLooper()).post(runnable);