为什么敬酒词比它的内容更短的宽度是多少? [英] Why is the width of toast shorter than its content?

查看:222
本文介绍了为什么敬酒词比它的内容更短的宽度是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了包含导航抽屉(里面一个ListView一个简单的片段),和一个模型,并为ListView适配器的活动。有一个ImageView的,并在一个列表项一个TextView,因为它通常是在许多应用程序。这就是我所做的一切,并且都搭载Android Studio自动生成的,其余$ C $活动的CS和片段的类。然后,当我用 Toast.makeText 在活动,结果看起来的这个

I wrote an activity which contains a navigation drawer (a simple fragment with a ListView inside), and a model and an adapter for the ListView. There is an ImageView and a TextView in a single list item, as it's usually be in many apps. That's all I have done, and the rest codes of the activity and fragment's classes were all generated automatically by Android Studio. Then when I used Toast.makeText in the activity, the result looks as this.

我搜索过这个问题,并使用 Toast.makeText试过(this.getApplicationContext(),...)而不是敬酒。 makeText(这个......),和它的工作。我不知道为什么会出现这种情况,我怎么应该正确解决了这个问题?

I've searched for this question and tried using Toast.makeText(this.getApplicationContext(), ...) instead of Toast.makeText(this, ...), and it worked. I'm wondering why would this happen and how should I solved this problem correctly?

推荐答案

官方文档它说,一个典型的面包看起来是这样的:

In the official documentation it says that a typical Toast looks like this:

Context context = getApplicationContext();
Toast toast = Toast.makeText(context, text, duration);

我想这是因为这取决于你有类,背景各不相同,因为不是所有的上下文实例都是平等的。

I imagine it is because depending on the class you have, the context varies because not all context instances are created equal.

更多信息还这里

这篇关于为什么敬酒词比它的内容更短的宽度是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆