Print numbers and strings on the Snackbar in java

Viewed 47

I am to make a temperature converter app. I need the result to be displayed in the form of a Snackbar.

  • used the Double.parseDouble() to convert the string editName to double.

How do I print it on Snackbar?

My code:

    Snackbar.make(view,"Temperature is" +text.getText().toString(),Snackbar.LENGTH_LONG);

[The app: 1 PS: I am new and not allowed to use images . I don't have enough reputation points.

1 Answers

This should do the trick:

Snackbar.make(
    view,
    String.format("Temperature is %f", Double.parseDouble(text.getText()),
    Snackbar.LENGTH_LONG
).show();
Related