gpt4 book ai didi

android - 从其 Toast 对象获取 toast 消息

转载 作者:行者123 更新时间:2023-11-28 21:01:31 29 4
gpt4 key购买 nike

有没有办法在 android 中获取与特定 android Toast 对象关联的消息?

toast=Toast.makeText(getAppContext(), message, Toast.LENGTH_LONG);
toast.show();

现在在我的测试类中,我想从这个 toast 对象获取消息

最佳答案

Is there a way to get the message associated with a particular android Toast object in android?

这样做:

Toast toast=Toast.makeText(getAppContext(), message, Toast.LENGTH_LONG);
toast.show();
View view = toast.getView();
TextView tv = (TextView)view.findViewById(android.R.id.message);
String strMessage=tv.getText().toString();

关于android - 从其 Toast 对象获取 toast 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29160200/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com