fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_SHORT) .setAction("Action", null).show(); } }); |
2 answers
It is better to make a button in Snackbar for this, when the user clicks this button, he will go to the site.
Snackbar.make(findViewById(R.id.my_layout), R.string.string_description, Snackbar.LENGTH_LONG) .setAction(R.string.name_button, new View.OnClickListener() { @Override public void onClick(View view) { Intent browserIntent = new Intent(Intent.ACTION_VIEW); browserIntent.setData(Uri.parse("www.example.com")); startActivity(browserIntent); } }).show(); } - Better! = Required - Flippy
|
Pass the text
SnackBar.make(view, Html.fromHtml("<a href=\"ссылка\">тыц</a>", ......) AND
TextView snackMessage = snackBar.findViewById(android.support.design.R.id.snackbar_text); textMessage.setMovementMethod(LinkMovementMethod.getInstance()); |
