Вопрос

I'm trying to create a static utility class which will contain simple functions like Messagebox(AlertDialog), EmailSender, etc... and will call these functions on other activites. But as I understand I can not create a static class if it is not in a class. What do you suggest for this kind of utility classes?

Это было полезно?

Решение

Why not make it that way

class Utils{
    public static void makeToast(Context context, String text){
        Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
    }
}

In your activity call it this way

Utils.makeToast(this,"hi");
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top