Tuesday 22 October 2024

Android SnackBar with Action Example

Android SnackBar with Action Example


 void showSnackBarWithMessage()

{
String message = "Message";
final Snackbar snack = Snackbar.make(layoutWebView, message, 2000);
snack.getView().setBackgroundColor(ContextCompat.getColor(this, R.color.purple_700));

snack.setAction("OK", new View.OnClickListener() {
@Override
public void onClick(View view) {
snack.dismiss();
}
});

snack.show();
}

No comments:

Post a Comment