Andorid Toast peut être utilisé pour afficher des informations pendant une courte période. Un toast contient un message à afficher rapidement et disparaît après un certain temps.
Vous pouvez également créer des toasts personnalisé ainsi
//Creating the LayoutInflater instance
LayoutInflater li = getLayoutInflater();
//Getting the View object as defined in the customtoast.xml file
View layout = li.inflate(R.layout.customtoast,
(ViewGroup) findViewById(R.id.custom_toast_layout));
//Creating the Toast object
Toast toast = new Toast(getApplicationContext());
toast.setDuration(Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setView(layout);//setting the view of custom toast layout
toast.show();
OR ..
Toast toast=Toast.makeText(getApplicationContext(),"Hello Javatpoint",Toast.LENGTH_SHORT);
toast.setMargin(50,50);
toast.show();
Vous pouvez utiliser des boucles pour une durée
il disparaît automatiquement après l'intervalle de temps. –
Non. Quand je règle LENGTH_LONG, il restera quelques secondes. Mais quand je clique sur le Toast, il se ferme sans rester pendant quelques secondes. Je veux garder Toast pendant quelques secondes sans disparaître mais je clique dessus. – thinuwan
Eh bien, vous devez créer votre propre Toast et gérer le comportement là-bas. Visitez ici pour en créer un: https://developer.android.com/guide/topics/ui/notifiers/toasts.html –