Last active
August 29, 2015 14:12
-
-
Save rburgosnavas/fda688f13671faa2a3bf to your computer and use it in GitHub Desktop.
A simple Toast helper class for Android.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.widget.Toast; | |
/** | |
* Helper class to make Toasts with. | |
*/ | |
public class Skal { | |
/** | |
* Creates a Toast. | |
* | |
* @param context The context. | |
* @param isLong Whether the Toast should have a Toast.LENGTH_LONG or Toast.LENGTH_SHORT. | |
* @param text The text to display in the Toast. | |
*/ | |
public static void make(Context context, boolean isLong, String text) { | |
int duration = isLong ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT; | |
Toast.makeText(context, text, duration).show(); | |
} | |
/** | |
* Creates a Toast with duration = Toast.LENGTH_LONG. | |
* | |
* @param context The context. | |
* @param text The text to display in the Toast. | |
*/ | |
public static void make(Context context, String text) { | |
make(context, true, text); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment