简体   繁体   English

Android Studio:此处不允许注释错误

[英]Android Studio: Annotations are not allowed here error

Don't know why this error is coming. 不知道为什么会出现此错误。 I have used the same logic of adding @Override in my previous apps (Which I learned from Udacity). 我在以前的应用程序中使用了@Override的相同逻辑(这是我从Udacity中学到的)。

I'm currently doing the Multiscreen Apps course. 我目前正在参加“ 多屏应用”课程。 Do let me know if anyone else have completed this course or having the same error. 请让我知道是否有人完成了本课程或存在相同的错误。

Here's what I wrote: 这是我写的:

//Find the view that shows family category
TextView family = (TextView) findViewById(R.id.family);

//Send a clicklistner on that view
family.setOnClickListener(new View.OnClickListener()

{
    @Override //here's the error
    public void onClick (View v){

    // create a new intent to open the {@link FamilyActivity}
    Intent familyIntent = new Intent(MainActivity.this, FamilyActivity.class);

    // start the new activity
    startActivity(familyIntent);
}
});

Thanks, Kvaibhav01. 谢谢,Kvaibhav01。

Did you try this? 你有尝试过吗?

  family.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub

            }
        });

我记得textView没有onClickListener,但是有onTouchListener,也许这是一个问题

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

相关问题 Android Studio:@Override“此处不允许使用注释” - Android Studio: @Override “Annotations are not allowed here” '这里不允许注释' - 'Annotations are not allowed here' CSS不允许使用@FindBy注解 - @FindBy Annotations not allowed here for CSS Android Studio 数据绑定中不允许元素数据 - Element data is not allowed here in Android Studio data binding 错误:此处不允许变量声明 - Error: Variable declaration not allowed here 错误:此处不允许使用“无效”类型 - Error: 'void' type not allowed here Android Studio:Manifest.xml中无法识别的密钥库条目+“此处不允许使用Android属性” - Android Studio : unrecognized keystore entry + “android attributes not allowed here” in Manifest.xml 此处不允许使用属性 android 并显示此消息“Error:(42) Error parsing XML: not well-formed (invalid token)” - Attribute android is not allowed here and show this message “Error:(42) Error parsing XML: not well-formed (invalid token)” Android Studio 构建错误:“序言中不允许使用内容。” - Android Studio Build Error: "Content is not allowed in prolog." Android Studio启动-MaxJavaStackTraceDepth = -1超出允许范围-错误 - Android Studio Startup - MaxJavaStackTraceDepth = -1 is outside the allowed range - ERROR
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM