Is it possible to get the value of string of Toast.makeText()?

江枫思渺然 提交于 2021-02-08 10:20:45

问题


If possible, I'd like to put the value of it to conditional statement (if) and put some arguments inside of it.


回答1:


You can do like this:

Toast myToast = Toast.makeText(this, "Hellow World!!!", Toast.LENGTH_SHORT);
        myToast.show();

//Now the statement below gets the text displayed 
String displayedText = ((TextView)((LinearLayout)myToast.getView()).getChildAt(0)).getText().toString(); 


来源:https://stackoverflow.com/questions/33982322/is-it-possible-to-get-the-value-of-string-of-toast-maketext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!