找不到符号“上下文”,android.content.Context
我有以下代码:
package com.androidtest.notification;import android.app.Activity;
import android.os.Bundle;
import android.widget;
import android.widget.Toast;
import android.content.Context;
public class activityNotification extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
}
我正在尝试在命令行“ $ ant build”上使用ant对其进行编译,但我不断收到以下错误:
error: cannot find symbol[javac] Context context = getApplicationContext();
[javac] ^
有什么建议吗?谢谢!
回答:
简短答案:添加此
import android.content.Context;
以上是 找不到符号“上下文”,android.content.Context 的全部内容, 来源链接: utcz.com/qa/414725.html