-2

how I can use toast inside of a thread? sorry for my english

Toast.makeText(this, "Show Toast", Toast.LENGTH_SHORT).show();

this not work? I am new in android.

Lo siento por mi ingles, es muy malo.

jodarove
  • 9
  • 2

1 Answers1

0

You can do it by calling an Activity's runOnUiThread method from your thread:

activity.runOnUiThread(new Runnable() {
    public void run() {
        Toast.makeText(activity, "Hello", Toast.LENGTH_SHORT).show();
    }
});

Taken from here

Community
  • 1
  • 1
crocboy
  • 2,887
  • 2
  • 22
  • 25