Toast.getView() returns null on Android 11 (API 30)

Since Android 11, custom toasts/ toast modifications are deprecated, according to Google to “protect users”. Hence why your app in Android 30 is not able to display custom toasts. From Android Developers documentation: Custom toast views are deprecated. Apps can create a standard text toast with the makeText(android.content.Context, java.lang.CharSequence, int)

What is the android.widget.Toast equivalent for iOS applications?

I’ve been writing for Android for a long time and I am missing Toast. I’ve implemented one. Need code? here you are: ToastView.h #import <UIKit/UIKit.h> @interface ToastView : UIView @property (strong, nonatomic) NSString *text; + (void)showToastInParentView: (UIView *)parentView withText:(NSString *)text withDuaration:(float)duration; @end ToastView.m #import “ToastView.h” @interface ToastView () @property (strong, nonatomic, readonly) UILabel *textLabel; @end … Read more

how can I change the color of Toast depends on message type in Angular material $mdToast?

There is an easier way by specifying a theme: $mdToast.simple().content(“some test”).theme(“success-toast”) And in your CSS: md-toast.md-success-toast-theme { background-color: green; … } You could incorporate your message type to dynamically select a theme. Update: As Charlie Ng pointed out, to avoid warnings regarding use of an unregistered custom theme register it in your module using the … Read more

Android: How to set the colour of a Toast’s text

You can achieve this very easily, without creating a custom layout by modifying the default Toast : Toast toast = Toast.makeText(this, resId, Toast.LENGTH_SHORT); TextView v = (TextView) toast.getView().findViewById(android.R.id.message); v.setTextColor(Color.RED); toast.show(); You can find the layout used by the default toast view in the Android SDK : $ANDROID-SDK$/platforms/android-8/data/res/layout/transient_notification.xml