Toast Unified Management Class:
1, short time display toast;
2, long time display Toast;
3. Custom display Toast time.
1 ImportAndroid.content.Context;2 ImportAndroid.widget.Toast;3 4 //Toast Unified Management Class5 Public classT6 {7 8 PrivateT ()9 {Ten /*cannot be instantiated*/ One Throw NewUnsupportedoperationexception ("cannot be instantiated"); A } - - Public Static BooleanIsshow =true; the - /** - * Short time display Toast - * + * @paramContext - * @parammessage + */ A Public Static voidShowshort (Context context, charsequence message) at { - if(isshow) - Toast.maketext (context, message, Toast.length_short). Show (); - } - - /** in * Short time display Toast - * to * @paramContext + * @parammessage - */ the Public Static voidShowshort (Context context,intmessage) * { $ if(isshow)Panax Notoginseng Toast.maketext (context, message, Toast.length_short). Show (); - } the + /** A * Long time display Toast the * + * @paramContext - * @parammessage $ */ $ Public Static voidShowlong (Context context, charsequence message) - { - if(isshow) the Toast.maketext (context, message, Toast.length_long). Show (); - }Wuyi the /** - * Long time display Toast Wu * - * @paramContext About * @parammessage $ */ - Public Static voidShowlong (Context context,intmessage) - { - if(isshow) A Toast.maketext (context, message, Toast.length_long). Show (); + } the - /** $ * Custom Display Toast time the * the * @paramContext the * @parammessage the * @paramDuration - */ in Public Static voidShow (context context, charsequence message,intduration) the { the if(isshow) About Toast.maketext (context, message, duration). Show (); the } the the /** + * Custom Display Toast time - * the * @paramContextBayi * @parammessage the * @paramDuration the */ - Public Static voidShow (Context context,intMessageintduration) - { the if(isshow) the Toast.maketext (context, message, duration). Show (); the } the -}
Android Development Tools Class 10_toast Unified management class