Android中的不同Toast消息

时间:2014-11-28 09:28:02

标签: android android-4.4-kitkat android-context android-toast

在我的Android应用程序中,我通过提供getApplicationContext()MainActivity.this

获得了两种不同类型的Toast消息

方法1:

Toast.makeText(getApplicationContext(),"No more items.", Toast.LENGTH_LONG).show();

产生以下输出:

enter image description here

方法2:

Toast.makeText(MainActivity.this,"No more items.", Toast.LENGTH_LONG).show();

第二种方法产生以下与第一种不同的吐司消息。

enter image description here

我不知道getApplicationContext()MainActivity.this之间产生两个不同的Toast消息的原因。请分享差异背后的原因。

我在Kitkat 4.4.2

中的Android Samsung S4.下运行

2 个答案:

答案 0 :(得分:3)

getapplication context返回应用程序的上下文,它在整个应用程序中保持相同。但是。这个上下文返回特定于活动的上下文。

答案 1 :(得分:1)

您的应用程序以Samsungs'为主题。 TouchWiz UI

相关问题