需在主线程中操作
方法1(推荐):
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { @Override public void run() { doSomething(); } },2000);
方法2:
runOnUiThread(new Runnable() { @Override public void run() { new Handler().postDelayed(new Runnable() { @Override public void run() { doSomething(); } },2000); } }