显示:同时做两项吐司消息? [英] Display two Toast messages at once?

查看:298
本文介绍了显示:同时做两项吐司消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个烤面包的消息在一个位置和不同的消息显示,可显示其他位置。

I would like one Toast message to display in one location and a different message to display in another location simultaneously.


  1. 多重敬酒的消息似乎总是为了排队和显示。是否有可能在同一时间同时显示消息?

  1. Multiple Toast messages seem to always queue and display in order. Is it possible to show both messages at the same time?

有一种解决方法,至少给出的外观,不涉及与活动布局弄乱?

Is there a workaround that at least gives that appearance that doesn't involve messing with the activity layout?

编辑:这似乎回答的第一个问题是没有,这是不可能的。怎么样解决方法吗?一个对我的解决方案将包括出现过度像吐司的应用程序,并且不与应用程序(所以,不是AlertDialogue或任何调用的onPause()等)的用户交互干扰的东西。

It seems the answer to the first question is no, it's not possible. How about a workaround? A solution for me would include something that appears "over" the app like a Toast and doesn't interfere with user interaction with the app (so, not an AlertDialogue or anything that calls onPause() etc.).

推荐答案

梦的表示,它不能这样做。但是,解决方法!您可以创建自定义的吐司其中可以包含任何查看。这意味着你可以有布局的两个的邮件上的不同的一个面包里面的地方。

As S͢ky D͢ream said, it cannot be done. But there IS workaround! You can create custom Toast which can contain any View. That means you can have layout with two messages on different places inside one toast.

您可以找到如何做到这一点 rel=\"nofollow\">或者你可以在这个片段中直接启动:

You can find how to do that here, or you can start directly with 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();

这篇关于显示:同时做两项吐司消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆