开发者

Android onClick jump to current location and activate LocationListener

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜