Example:
Timer t = new Timer(false);
t.schedule(new TimerTask() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), "msg", Toast.LENGTH_LONG).show();
}
}, 5000);
However, I did find out a solution. It works well.
final Context ctx = this;
Handler mHandler = new Handler();
Runnable
makeToast = new Runnable() {
public void run() {
Toast.makeText(ctx,
"msg", Toast.LENGTH_LONG).show();
}
};
mHandler.postDelayed(makeToast, 1000);
沒有留言:
張貼留言