无法覆盖LocationListener类的方法 [英] Unable to override methods of LocationListener class

查看:97
本文介绍了无法覆盖LocationListener类的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用GPS获取当前位置.

I want to get current location using GPS.

这是我的情况.我的班级定义是:

Here is my scenario. My class definition is:

public class UseGps extends Activity implements LocationListener

如果Í试图像这样重写LocationListener方法

If Í try to override the LocationListener methods like this

1)

@Override 
public void onLocationChanged(Location loc)

2)

@Override
public void onProviderDisabled(String provider)

3)

@Override
public void onProviderEnabled(String provider)

它给我说编译错误

The method onStatusChanged(String, int, Bundle) of type UseGps must override a superclass method remove override.

与2)和3)相同

这是怎么了?

推荐答案

假设您正在使用Eclipse,请执行以下操作以确保合规性级别为1.6.

Assuming that you are using Eclipse do the following to ensure that your compliance level is 1.6.

转到Project-> Properties-> Java Compiler.确保将Compiler compliance level设置为1.6.

Go to Project -> Properties -> Java Compiler. There make sure that Compiler compliance level is set to 1.6.

您应该通过导航到Window-> Preferences-> Java-> Compiler将该级别设置为默认值.为Compiler compliance level选择1.6.

You should set that level as a default value by navigating to Window -> Preferences -> Java -> Compiler. Select 1.6 for Compiler compliance level.

这篇关于无法覆盖LocationListener类的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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