Android中的定时弹出窗口

Isa*_*ler 12 java android timer popup

我正在为Android创建一个匹配游戏,当用户获得匹配时,会弹出一个对话框,说"匹配!" 我无法弄清楚如何做到这一点.如果我使用Thread.currentthread().sleep,则对话框永远不会出现.

android.app.AlertDialog a = new android.app.AlertDialog.Builder(match.this).setTitle("Match!").show();
Thread.currentthread().sleep(1000);
a.dismiss();
Run Code Online (Sandbox Code Playgroud)

什么都没发生 - 程序只挂了一秒钟.我希望它只弹出1秒,或者如果有另一种弹出式的东西,这也会很好.

Mar*_*amp 18

您是否试图在屏幕上短时间内在弹出窗口中显示短信?

对于这些警报敬酒很棒:

Toast.makeText(this, "Match!", Toast.LENGTH_LONG).show();
Run Code Online (Sandbox Code Playgroud)

那是你在找什么? 这是Java Doc.