本文介绍了吐司没有出现在Android 4.4奇巧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用吐司的应用程序,我已经使用Android 4.3测试它在三星Galaxy II,它工作正常。

I have an application that uses Toast and I have tested it on a Samsung Galaxy II using Android 4.3 and it works fine.

我最近得到了运行Android 4.4奇巧是Nexus 5,当我尝试加载吐司它不会出现。

I have recently gotten a Nexus 5 running Android 4.4 KitKat and when I try to load the Toast it doesn't appear.

的面包被删除或者改变奇巧的语法?

Has Toast been removed or the syntax altered in KitKat?

这是code我使用,使并调用吐司:

This is the code I'm using to make and call the Toast:

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item)
{
    int itemId = item.getItemId();
    switch (itemId) {

    case R.id.action_settings:
        Log.e("TOAST","This was called");
        Toast.makeText(MainActivity.this, "This is my Toast message!",Toast.LENGTH_LONG).show();
        break;
    }
    return true;
}

我已经调试的code,并通过线这一部分线踩所以它肯定是被称为,但没有任何反应。

I have Debugged the code and stepped through this part line by line so it is definitely being called, but nothing happens.

推荐答案

使用这个而不是 getApplicationContext()

这篇关于吐司没有出现在Android 4.4奇巧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 23:44