简体   繁体   English

android studio:不支持类型注释

[英]android studio: type annotations are not supported

I simply referred to an already defined string, like this 我简单地提到了一个已定义的字符串,就像这样

Entry in MainActivity.java 在MainActivity.java中输入

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
        case R.id.res_learn:
            textview1settext(@string/str_learn);
            return true;
        case R.id.res_test:
            textview1settext(@string/str_test);
            return true;
        case R.id.res_result:
            textview1settext(@string/str_result);
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}

And these references to strings causes at compilation time the error: 这些对字符串的引用会在编译时导致错误:

Error:(56, 35) error: type annotations are not supported in -source 1.7 (use -source 8 or higher to enable type annotations) 错误:(56,35)错误:-source 1.7不支持类型注释(使用-source 8或更高版本启用类型注释)

Now what? 怎么办? I actualized Android Studio within the last few weeks as proposed by the programm. 我按程序的建议在过去几周内实现了Android Studio。 As far as I understand these updates were no actualisation, I loaded down somewhat older. 据我所知,这些更新没有实现,我加载了一些旧版本。 Or has this error-message another reason. 或者有这个错误消息的另一个原因。 How do I fix this error. 我该如何解决这个错误。

Try to use: 尝试使用:

textview1settext(R.string.str_learn); textview1settext(R.string.str_learn);

Btw just try to find some course about android development for beginners. 顺便试试为初学者找到一些关于android开发的课程。 For example on Coursera or Udacity. 例如,在Coursera或Udacity上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM