Wednesday, September 30, 2020

Showing Snackbar with action button in Android

Showing Snackbar with  action button in Android 


void showSnackBarWithMessage(String message)
{

final Snackbar snack = Snackbar.make(yourView, message, 3000);
snack.getView().setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.colorPrimaryLight));
snack.setAction("OK", new View.OnClickListener() {
@Override
public void onClick(View view) {
snack.dismiss();
}
});

snack.show();
}

No comments:

Post a Comment