Java – display integers on toast

I tried to display a toast message with an integer in it

Toast.makeText(this,bignum,Toast.LENGTH_LONG).show();

But it keeps crashing my app Thanks for your help!

Solution

Toast. Maketext uses either charsequence or int as its second argument

However, int represents the resource ID (for example, r.string.hello_world)

The application may crash because the resource with this ID was not found because it is not an ID, but an arbitrary integer

In your case, use toast makeText(this,String.valueOf(bignum),Toast. LENGTH_ LONG). show();.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>