简体   繁体   English

为活动实现View.OnClickListener-方法不会被覆盖

[英]Implementing View.OnClickListener for the activity - method is not overriden

Here is my activity code: 这是我的活动代码:

public class TextsListActivity extends ActionBarActivity implements View.OnClickListener {

    @Override
    public void OnClick(View button) {

    }
}

Android Studio warns that Method does not override method from its superclass and also another warning that TextsListActivity should implement onClick . Android Studio警告Method does not override method from its superclass ,还警告TextsListActivity应该实现onClick What have I done wrong? 我做错了什么?

The declaration of the method has a lowercase letter " o ", you're really not overriding the one you think you are. 该方法的声明使用小写字母“ o ”,您实际上并没有覆盖您认为的那个。 Keep in mind that the view may or may not be a Button , any View can potentially receive a click event. 请记住,该视图可能是Button ,也可能不是Button ,任何View都可能接收到click事件。

 public void onClick(View v) {} //as opposed to OnClick


Tip: The next time, if you press alt while having the cursor on an error you will be prompted with some possible solutions to the situation. 提示:下次,如果在光标停留在错误上的同时按alt you ,则会提示您一些解决方案。 In this case, it would've suggested to implement onClick(View v) 在这种情况下,建议您实现onClick(View v)

暂无
暂无

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

相关问题 View.OnClickListener,方法还是类? - View.OnClickListener, method or class? View.OnClickListener 没有切换到另一个活动 - View.OnClickListener not switching to another activity 视图类型中的方法setOnClickListener(View.OnClickListener)不适用于自变量(起点) - The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (startingpoint) Android对于new View.OnClickListener(){}类型,未定义方法startActivity(Intent) - Android The method startActivity(Intent) is undefined for the type new View.OnClickListener(){} 新的View.OnClickListener类型必须实现继承的抽象方法 - The type new View.OnClickListener must implement the inherited abstract method 对于新的View.OnClickListener(){}类型,未定义方法userAccounts() - The method userAccounts() is undefined for the type new View.OnClickListener(){} 在View.OnCLickListener中侦听onActivityResault - Listening for onActivityResault in View.OnCLickListener View.OnClickListener()一个函数或接口 - View.OnClickListener() a function or Interface 新的OnClickListener()与新的View.OnClickListener() - new OnClickListener() vs new View.OnClickListener() 视图类型中的方法setOnClickListener(View.OnClickListener)不适用于自变量(新DialogInterface.OnClickListener(){}) - The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (new DialogInterface.OnClickListener(){})
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM