Display two Toast messages at once?

I would like one Toast message to be displayed in one place and another Toast message to be displayed in another place at the same time.

  • Several Toast messages always appear in the queue and are displayed in order. Is it possible to simultaneously display both messages?

  • Is there a workaround that at least gives such an appearance and is not related to using an activity layout?

Edit: It seems the answer to the first question is no, this is not possible. How about a workaround? The solution for me would include something that appears on top of the application, such as Toast, and does not interfere with the user interaction with the application (so not AlertDialogue or anything that calls onPause (), etc.).

+7
android toast android-toast
source share
2 answers

Like SΝ’ky DΝ’ream said this is not possible. But there is a workaround! You can create a custom Toast that can contain any View . This means that you can have a layout with two messages in different places inside the same toast.

You can find how to do it here , or you can start right from this snippet:

 LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.toast_layout_root)); TextView text = (TextView) layout.findViewById(R.id.text); text.setText("This is a custom toast"); Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); 
+4
source share

The short answer is no, you cannot

You cannot show 2 Toast at the same time. I am sure of this, I have already tried it, but I can only display one Toast.

But if you want to display two toasts at the same time, then you will set the flow mechanism one by one in the same place, one after another.

+3
source share

All Articles