最終更新:2013-01-28 (月) 01:32:13 (4077d)
Activity.runOnUiThread
Top / Activity.runOnUiThread
public final void runOnUiThread (Runnable action)
動作
- Runs the specified action on the UI thread.
- If the current thread is the UI thread, then the action is executed immediately.
- If the current thread is not the UI thread, the action is posted to the event queue of the UI thread.
例
private void toast(final String message) { runOnUiThread(new Runnable() { @Override public void run() { Context context = getApplicationContext(); int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, message, duration); toast.show(); } }); }