ToastUtils,此工具类不是网上大家用烂的那一份,是博主亲自编写,亲自测试,代码简洁清晰,可满足日常开发。
import android.content.Context;
import android.widget.Toast;
/**
* Created on 2021/4/2 14:00
*
* @author Gong Youqiang
*/
public class ToastUtils {
private static Toast toast = null; //Toast的对象!
public static void showToast(Context mContext, String id) {
if (toast == null) {
toast = Toast.makeText(mContext, id, Toast.LENGTH_SHORT);
}
else {
toast.setText(id);
}
toast.show();
}
}
网友评论