package cn.net.caoyao.cpzshandset.ui.weight;

import android.content.Context;
import android.widget.Toast;

/**
 * Created by Echo on 2016/6/20.
 */
public class MyToast {
    Context mContext;
    Toast mToast;

    public MyToast(Context context) {
        mContext = context;

        mToast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
        mToast.setGravity(17, 0, -30);//居中显示
    }

    public void show(int resId, int duration) {
        show(mContext.getText(resId), duration);
    }

    public void show(CharSequence s, int duration) {
        mToast.setDuration(duration);
        mToast.setText(s);
        mToast.show();
    }

    public void cancel() {
        mToast.cancel();
    }
}
