[英]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.