A
A
Anrek2021-09-21 15:04:23
Java
Anrek, 2021-09-21 15:04:23

How to replace Toast? Or how to show a simple alert?

Good afternoon! It is necessary to display a message at the top of the screen in 2 words

in 1 place of the application . Tried Toast:

val text  = "Текст сообщения"
        val toast = Toast.makeText(context, text, Toast.LENGTH_SHORT)
        toast.setGravity(Gravity.TOP, 0, 0) 
        toast.show()


The message is displayed, but setGravity does not work., i.e. the message is displayed at the bottom and closes the button. The documentation says that setGravity does not run in new API versions.

How to replace Toast?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dee_Nice, 2021-09-22
@Anrek

Are you going through the Big Nerd Ranch book?) Also stuck on this. You can try Snackbar as I read, but to be honest, I still didn’t figure out how to implement this thing and stupidly changed the API version)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question