I am creating a matching game for Android, and when the user gets a match, a dialog box should pop up saying ‘Match!’ I cannot figure out how to do this though. If I use Thread.currentthread().sleep, the dialog never appears.
android.app.AlertDialog a = new android.app.AlertDialog.Builder(match.this).setTitle('Match!').show(); Thread.currentthread().sleep(1000); a.dismiss();
Nothing happens – the program just hangs for a second. I would like it to pop up for just 1 second, or if there is another sort of popup type thing, that would be good too.
You’re trying to show a text message in a popup for a short period of time on the screen?
For these kind of alerts toasts are great:
Is that what you are looking for? Here is the Java Doc.