public class CustomerToast extends Toast {
/**
* 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.
*/
private TextView contentTv;
public CustomerToast(Context context) {
super(context);
View view = LayoutInflater.from(context).inflate(R.layout.toast_ll, null);
contentTv = view.findViewById(R.id.content_tv);
setView(view);
}
public static CustomerToast makeToast(String content) {
CustomerToast customerToast = new CustomerToast(MyApplication.getInstance());
customerToast.setDuration(Toast.LENGTH_SHORT);
customerToast.setGravity(Gravity.CENTER, 0, 0);
customerToast.contentTv.setText(content);
return customerToast;
}
}