Android error: The method onClick (View) of type new View. OnClickL

Source: Internet
Author: User

Recently, the following error was reported during a jWebSocket Android client Demo:


"...... The method onAccuracyChanged (Sensor, int) of type Fundamentals must override a superclass ......"
"...... The method onClick (View) of type new View. OnClickListener () {} must override a superclass ......"

"... The method onSensorChanged (SensorEvent) of type Fundamentals must override a superclass ......"


The Code is as follows:

[Java]
LBtnSend. setOnClickListener (new OnClickListener (){
 
@ Override
Public void onClick (View arg0 ){
// TODO Auto-generated method stub
Try {
JWC. broadcastText ("pause ");
} Catch (WebSocketException ex ){
 
 
}

Log (lBtnSend. getText ());
If (lBtnSend. getText (). equals ("Pause ")){
LBtnSend. setText ("Begin ");
} Else {
LBtnSend. setText ("Pause ");
}
}
 
 
});
......
......
@ Override
Public void onAccuracyChanged (Sensor arg0, int arg1 ){
......
}
 
@ Override
Public void onSensorChanged (SensorEvent event ){
......
}


Find the jdk version.

Solution:

In Eclipse, choose Project Properties> javaCompiler and find complier compliance level to change 1.5 to 1.6. That is to say, the Java 1.5 compiler overwrites the method of the parent class by default and uses @ Override to describe it. However, 1.6 has been extended to the method of the interface, therefore, an error occurs if it is still compiled using the Java 1.5 compiler. The java compiler version is 1.6. You only need to set the compilation level to 1.6.


From column zyz316919766

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.