android.content.context 找不到,找不到符号“上下文”,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 activityN
我有以下代码:
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] ^
有什么建议吗?谢谢!
更多推荐
所有评论(0)