从其 Toast 对象获取 toast 消息

ali*_*tha 0 testing android toast

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

toast=Toast.makeText(getAppContext(), message, Toast.LENGTH_LONG);
toast.show();
Run Code Online (Sandbox Code Playgroud)

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

ρяσ*_*я K 5

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

这样做:

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();
Run Code Online (Sandbox Code Playgroud)