开发者

Android onClick jump to current location and activate LocationListener

开发者 https://www.devze.com 2023-03-13 11:19 出处:网络
This was created with guidance from Kaj (below) Figured my problem out, but this may be useful for someone else looking to jump to current users location:

This was created with guidance from Kaj (below)

Figured my problem out, but this may be useful for someone else looking to jump to current users location:

boolean touched = false;

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

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

@Override
public bool开发者_开发知识库ean onTouchEvent(MotionEvent event, MapView mapView) 
    {   
//---when user lifts his finger---
if (event.getAction() == 1) {
    touched = true;
     }
return false;
}


Your onClick should say touched = "no"; and not String touched = "no";. Btw, it's probably better to change it to a boolean, so that you have true/false, instead of having strings. You should normally not compare strings with ==, use string.equals(anotherString) instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消