吐司工具類--ToastUtil
/**
- Created by peng on 2015/6/15.
- 吐司工具類 */ public class ToastUtil { private static Toast TOAST; private static final String TAG = "ToastUtil";
//短時間吐司
public static void show(Context context, int resourceID) {
show(context, resourceID, Toast.LENGTH_SHORT);
}
//短時間吐司
public static void show(Context context, String text) {
show(context, text, Toast.LENGTH_SHORT);
}
//自定義時長吐司
public static void show(Context context, Integer resourceID, int duration) {
String text = context.getResources().getString(resourceID);// 用于顯示的文字
show(context, text, duration);
}
//自定義時長吐司
public static void show(@NonNull final Context context, @NonNull final String text, final int duration) {
if (TOAST == null) {
TOAST = Toast.makeText(context, text, duration);
} else {
TOAST.setText(text);
TOAST.setDuration(duration);
}
TOAST.show();
}
}</pre>
本文由用戶 bugyw 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!