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();
}

2 comments:

  1. I appreciate the thorough explanation of how to show a snackbar with an action button in Android. ipvanish 5 year plan The instructions are clear and easy to follow, making it simple for anyone to implement this feature in their app.

    ReplyDelete