自定义View继承现有的Toast,实现订单提醒的Toast,从左下角显示然后退出
/**
* Created by on 16-2-4.
*/
public class NotifyToast extends Toast {
private long lastShowTime;
public static NotifyToast instance;
public static synchronized NotifyToast getInstance(Context context){
if(instance==null){
instance = new NotifyToast(context,"你有未处理的订单,请抓紧处理",3000);
}
return instance;
}
private MediaPlayer mPlayer;
/**
* Construct an empty Toast object. You must call {@link #setView} before you
* can call {@link #show}.
*
* @param context The context to use. Usually your {@link Application}
* or {@link Activity} object.
*/
public NotifyToast(Context context,CharSequence text, int duration) {
super(context);
mPlayer = MediaPlayer.create(context, R.raw.neworder);
//2016年08月02日10:51:32 不需要设置完成后释放资源的回调,整段注释掉了
//