每次用户更改位置时,我想通知用户。我在里面插入了烤面包,onLocationChanged
但是在makeText
from上有一条红线toast.makeText
。它说
The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (CurrentLocationOverlay, String, int)
然后我从
Toast.makeText(this,"Your current speed is :" +gps.getSpeed, Toast.LENGTH_SHORT).show()
至Toast.makeText(getBaseContext(),"Your current speed is :" +gps.getSpeed, Toast.LENGTH_SHORT).show().
然后它告诉我创建getBaseContext()
方法。我什至把它改成了getApplicationContext()
. 还是一样的答案。甚至改成类名还是一样
公共类 CurrentLocationOverlay 扩展 MyLocationOverlay {
GPSTracker gps;
@Override
public synchronized void onLocationChanged(Location location) {
super.onLocationChanged(location);
Toast.makeText(this,"Your current speed is :" +gps.getSpeed(),
Toast.LENGTH_SHORT).show();
// only move to new position if enabled and we are in an border-area
if (mc != null && centerOnCurrentLocation && inZoomActiveArea(currentPoint)) {
mc.animateTo(getMyLocation());
}}
}