All Products
Search
Document Center

Toast

Last Updated: May 25, 2021

AUToast is the page pop-up indicator, and the AUProgressDialog is a progress indicator.

When the Toast methods of BaseFragmentActivity and BaseActivity are used, the mPaaS framework modifies the pop-ups in a unified manner.

For activity developed based on BaseFragmentActivity and BaseActivity, the system uses AUToast by default.

Sample images

AUToast

AUProgressDialog

Dependency

See Quick start.

API description

 
  1. /**
  2. * Instantiate Toast.
  3. *
  4. * @param context The context. Use activities on the current page.
  5. * @param drawableId Image resources.
  6. * @param tipSrcId The text prompt ID.
  7. * @param duration Display duration Toast.Long/Toast.Short.
  8. * @return Toast
  9. */
  10. public static Toast makeToast(Context context, int drawableId, int tipSrcId, int duration) {
  11. CharSequence tipSrc = context.getResources().getText(tipSrcId);
  12. return makeToast(context, drawableId, tipSrc, duration);
  13. }
  14. /**
  15. * Create Toast.
  16. *
  17. * @param context The context. Use activities on the current page.
  18. * @param tipSrcId The prompt information.
  19. * @param duration The duration.
  20. * @return toast
  21. */
  22. public static Toast makeToast(Context context, int tipSrcId, int duration) {
  23. CharSequence tipSrc = context.getResources().getText(tipSrcId);
  24. return makeToast(context, 0, tipSrc, duration);
  25. }
  26. /**
  27. * Make a toast that just contains a image view and a text view.
  28. *
  29. * @param context The context. Use activities on the current page.
  30. * @param drawableId The image resourceid.
  31. * @param tipSrc The text to show. Can be formatted text.
  32. * @param duration How long to display the message. Either or
  33. * @return
  34. */
  35. public static Toast makeToast(Context context, int drawableId, CharSequence tipSrc, int duration)

Code sample

 
  1. // Success.
  2. AUToast.makeToast(ToastActivity.this, com.alipay.mobile.antui.R.drawable.toast_ok, "Success prompt", Toast.LENGTH_SHORT).show();
  3. // Failure.
  4. AUToast.makeToast(ToastActivity.this, com.alipay.mobile.antui.R.drawable.toast_false, "Failure prompt", Toast.LENGTH_SHORT).show();
  5. }
  6. // Warning.
  7. AUToast.makeToast(ToastActivity.this, com.alipay.mobile.antui.R.drawable.toast_warn, "Warning prompt", Toast.LENGTH_SHORT).show();
  8. }
  9. // Text.
  10. AUToast.showToastWithSuper(ToastActivity.this, 0, "The text contains up to 14 words", Toast.LENGTH_SHORT);
  11. // Loading.
  12. AUProgressDialog dialog = new AUProgressDialog(this);
  13. dialog.setMessage("Loading");
  14. dialog.show();
  15. }