类型oddg的方法的onClick(视图)必须覆盖超类的方法? [英] The method onClick(View) of type oddg must override a superclass method?

查看:775
本文介绍了类型oddg的方法的onClick(视图)必须覆盖超类的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发生类似的错误:类型oddg的方法的onClick(视图)必须覆盖父类的方法:我很困惑的地方是发生完全错误.. 可以请你指导我,到底什么错误?????

i am occurring error like: "The method onClick(View) of type oddg must override a superclass method" i am confused where exactly error is occurred.. can you please guide me,what exactly error is?????

    public class oddg extends Activity implements OnClickListener
    {
            ProgressDialog dialog;
            int increment;
            int maximum ;
            private static final String TAG = "ServicesDemo";




            @Override
            public void onCreate(Bundle savedInstanceState) 
            {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main1);
                Button startbtn = (Button) findViewById(R.id.startbtn);
                startbtn.setOnClickListener(this);

            }


            @Override
            public void onClick(View arg0)
            { }
    }

这是我的code ... 提前致谢 - Onkar

this is my code... Thanks in Advance-- Onkar

推荐答案

我认为这个问题是,你的编译器设置被设置为Java 1.5,而不是Java的1.6。由于Java 1.6注释@Override不仅是可能的,用于从超类继承的方法也为从接口实现的方法。但是,如果你的编译器仍设置为1.5的问题是,他会检查,如果你从一个超类覆盖的方法。在你的榜样,这是不是因为你实现从接口的方法的情况。

I think the problem is that you're compiler settings are set to Java 1.5 instead of Java 1.6. Since Java 1.6 the annotation @Override is not only possible for inherited methods from a superclass but also for implemented methods from an interface. But if your compiler is still set to 1.5 the problem is that he will check if you're overwriting a method from a super class. In your example this is not the case since you're implementing a method from an interface.

作为一个侧面说明这将是很好的遵循 Java命名约定的中您的code。因此所有的类开头的大写字母。

As a side note it would be good to follow Java Naming Conventions in your code. So all classes begin with an upper case letter.

这篇关于类型oddg的方法的onClick(视图)必须覆盖超类的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆