0

这是在 Kaj 的指导下创建的(下)

解决了我的问题,但这对于希望跳转到当前用户位置的其他人可能有用:

boolean touched = false;

if(touched == false){
    mapController.animateTo(point);
}

myLocationBtn.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        touched = false;
    }
});

@Override
public boolean onTouchEvent(MotionEvent event, MapView mapView) 
    {   
//---when user lifts his finger---
if (event.getAction() == 1) {
    touched = true;
     }
return false;
}
4

1 回答 1

2

onClick应该说touched = "no";而不是String touched = "no";。顺便说一句,最好将其更改为布尔值,以便您拥有true/false,而不是字符串。您通常不应该将字符串与==,进行比较,string.equals(anotherString)而是使用。

于 2011-06-17T07:55:01.857 回答