0

我的游戏被绘制到SurfaceView. 我正在使用对话框作为关卡完成屏幕,但无法显示 ( Dialog.show())。

我不断收到以下错误:

01-30 16:45:34.425: E/AndroidRuntime(3415): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

我有一个 Game 类,它扩展了 Activity 并持有SurfaceView. 我认为runOnUiThread()可能是解决方案,但经过不知疲倦的搜索后,不知道如何在我的SurfaceView.

任何帮助表示赞赏,如果需要,我会发布我的代码(只是不确定目前哪些位实际上是相关的)

4

1 回答 1

1

您正在尝试从会给出这些错误的工作线程修改 UI 线程。为了防止这种情况,请尝试调用该runOnUiThread()方法...

Game.this.runOnUiThread(new Runnable() {
    public void run() {
        customDialogObject.show();
    }
});
于 2013-01-30T19:19:01.357 回答