我刚刚将 android studio 版本从 0.9.2 更新到 0.9.3,并打开一个现有项目(使用 0.9.2 运行)以下错误(红色下划线)出现在所有“.toString”方法中(f.i. Integer .toString): 非静态方法 toString() 不能从静态上下文中引用。但是调试没有显示任何内容,应用程序运行正常。请问有什么建议吗?
例子:
private String read(String nomefile)
{
String dati=null;
try{
FileInputStream fin=openFileInput(nomefile);
int c;
String temp="";
while ((c=fin.read())!=-1)
{
temp=temp+Character.toString(((char)c));
}
dati=temp;
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
return dati;
}
'.toString' 是红色下划线的注释:'non static method toString() cannot be referenced from a static context' 更新: 用“Character.valueOf(...)”替换“Character.toString(...)”似乎没问题(没有红色下划线)。这意味着 toString 方法将被弃用?
最佳答案
关于Android Studio 0.9.2 到 0.9.3 错误 : toString() method cannot be referenced,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26937002/