android - Toast 文本被截断
Toast 遇到一个奇怪的问题 - 我的应用程序中有一些问题可以在用户执行某些操作时通知用户,特别是出现显示问题。在模拟器上没问题,在我的合作开发者的 Android 手机上也没问题,但在我的手机上,第二行文本被切断。 Toast 显示为单行框,您可以看到被截断的第二行文本的顶部。还有其他人遇到过这个问题吗?这只是一个一般的错误吗?我用google也没找到问题所在!
msg = getString(R.string.notification_cancel_add);
Toast.makeText(AddEditActivity.this, msg, Toast.LENGTH_SHORT).show();
和 R.string.notification_cancel_add =
Coming across a weird issue with Toast - I have a few in my app to notify the user when they perform certain actions, and one in particular is having a display issue. It's fine on the emulator, and it's fine on my co-developer's android phone, but on my phone the second line of text gets cut off. The toast appears as a single line box and you can see the top of the second line of text that's getting cut off. Anyone else come across this issue? Is it just a general bug? I haven't been able to find the problem with google!
msg = getString(R.string.notification_cancel_add);
Toast.makeText(AddEditActivity.this, msg, Toast.LENGTH_SHORT).show();
and R.string.notification_cancel_add = <string name="notification_saved_message">Your Notification has been saved.</string>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这很奇怪。但我已经通过传递应用程序上下文解决了这个问题。
It is very weird . But I have solved it by passing the application context.
查看 Android 本地化的未来,此处。也许您必须为您的手机细节(显示等)编写额外的代码。就像你说的,它在其他设备上运行良好
Check out android localization futures, here. Maybe you have to code extra for your phone specifics (display, etc...). Like you said, it works fine with other devices
您必须使用应用程序上下文、getContext 或 MyClass.this
在 Activity 中,使用 getApplicationContext()
正如开发人员文档中所述:
来源:https://developer.android.com/guide/topics/ui/通知者/祝酒词
You have to use the application context, getContext or MyClass.this
In an Activity, use getApplicationContext()
As said in the developer documentation :
Source : https://developer.android.com/guide/topics/ui/notifiers/toasts