ToastUtil工具类

public class ToastUtil {
private static Toast mToast = null;
public static void showToast(Context context, String text, int duration) {
if (mToast == null) {
mToast = Toast.makeText(context, text, duration);
} else {
mToast.setText(text);
mToast.setDuration(duration);
}
mToast.show();
}
}

调用方法:
toastUtil.showToast(MainActivity.this, "tab1", Toast.LENGTH_SHORT);
posted @ 2017-04-14 21:09  Calo-missile  阅读(1579)  评论(0编辑  收藏  举报