Custom toast

This commit is contained in:
M66B
2019-07-13 08:58:56 +02:00
parent dcc43a1f1c
commit d488809a69
12 changed files with 81 additions and 30 deletions

View File

@@ -0,0 +1,25 @@
package eu.faircode.email;
import android.content.Context;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
public class ToastEx {
public static Toast makeText(Context context, int resId, int duration) throws Resources.NotFoundException {
return makeText(context, context.getText(resId), duration);
}
public static Toast makeText(Context context, CharSequence text, int duration) {
Toast toast = new Toast(context);
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.toast, null);
TextView tv = view.findViewById(android.R.id.message);
tv.setText(text);
toast.setView(view);
toast.setDuration(duration);
return toast;
}
}