在吐司上显示整数 [英] Displaying integer on toast
本文介绍了在吐司上显示整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在其中显示带有整数的toast消息
这是我尝试这样做的方式:
Im trying to display a toast message with integer inside it This is how i tried to do it:
Toast.makeText(this,bignum,Toast.LENGTH_LONG).show();
但它会让我的应用程序崩溃。
感谢您的帮助!
But it keeps crash my app. Thanks for help!
推荐答案
Toast.makeText
将 CharSequence
或 int
作为其第二个参数。
Toast.makeText
either takes a CharSequence
or an int
as its second argument.
然而, int
代表资源ID (例如 R.string.hello_world
)。
应用程序崩溃可能是因为没有找到带有该ID的资源,因为它不是ID从一开始,但是一个任意整数。
The application crashes probably because no resource is found with that ID, since it's not an ID to start with, but an arbitrary integer.
在你的情况下,使用 Toast.makeText(this,String.valueOf(bignum),Toast.LENGTH_LONG)。show();
。
这篇关于在吐司上显示整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文