0

我正在尝试从 IntentService 获取字符串资源值,如下所示:

String errorTitle = getResources().getString(R.string.no_Internet_connection_error_title);

但它显示一个错误no_Internet_connection_error_title cannot be resolved or is not a field

当我输入 时R.string.,eclipse 显示了一个 android 定义的字符串列表,不是我定义的。

我在活动中使用字符串资源,但无法在 IntentService 中使用。

4

1 回答 1

3

我认为其中一位发表评论的人会发布答案。但因为他们没有我发布它。

R.java解决方案是使用包名导入文件:

import com.android.myApp.R;

或者使用整个包名来获取字符串:

getResources().getString(com.android.myApp.R.string.no_Internet_connection_error_title);
于 2013-06-20T11:47:03.077 回答