package com.basic.security.widget;
|
|
import android.content.Context;
|
import android.view.LayoutInflater;
|
import android.view.View;
|
import android.widget.TextView;
|
import android.widget.Toast;
|
|
import com.basic.security.R;
|
|
public class MyToast {
|
private final TextView textView;
|
private Toast mToast;
|
private boolean isShow = false;
|
|
private MyToast(Context context, CharSequence text, int duration) {
|
View v = LayoutInflater.from(context).inflate(R.layout.eplay_toast, null);
|
textView = v.findViewById(R.id.textView1);
|
textView.setText(text);
|
mToast = new Toast(context);
|
mToast.setDuration(duration);
|
mToast.setView(v);
|
}
|
|
public static MyToast makeText(Context context, CharSequence text, int duration) {
|
return new MyToast(context, text, duration);
|
}
|
|
public void setText(CharSequence text) {
|
if (textView != null) {
|
textView.setText(text);
|
}
|
}
|
|
public void show() {
|
if (mToast != null) {
|
mToast.show();
|
}
|
}
|
|
public void setGravity(int gravity, int xOffset, int yOffset) {
|
if (mToast != null) {
|
mToast.setGravity(gravity, xOffset, yOffset);
|
}
|
}
|
|
public void setDuration(int duration) {
|
if (mToast != null) {
|
mToast.setDuration(duration);
|
}
|
}
|
|
}
|