【问题标题】:Is it possible to get the value of string of Toast.makeText()?是否可以获取 Toast.makeText() 字符串的值?
【发布时间】:2015-11-29 11:35:35
【问题描述】:

如果可能,我想将它的值放入条件语句 (if) 中,并在其中放入一些参数。

【问题讨论】:

  • 你的意思是从资源? Toast.makeText(c, c.getResources().getString(R.string.my_resource_string), Toast.LENGTH_SHORT).show();
  • 是否无法获取出现的 toast 消息的值。就像吐司消息是你好一样。然后,你可以得到它的值,你可以用toast消息的使用来做条件吗?对不起,如果不是。我只是 android 新手。

标签: android android-toast


【解决方案1】:

你可以这样做:

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(); 

【讨论】:

  • 你去,你明白了(Y)
猜你喜欢
  • 1970-01-01
  • 2011-12-21
  • 1970-01-01
  • 1970-01-01
  • 2017-11-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-26
相关资源
最近更新 更多