开发者

The method getBaseContext() is undefined for the type MyMapOverlay in android? why?

开发者 https://www.devze.com 2022-12-22 02:36 出处:网络
i am creating a Geocoder object like. Geocoder geoCoder = new G开发者_JS百科eocoder(getBaseContext(), Locale.getDefault());

i am creating a Geocoder object like.

Geocoder geoCoder = new G开发者_JS百科eocoder(getBaseContext(), Locale.getDefault());

here i got this error in eclipse. i.e.

The method getBaseContext() is undefined for the type MyMapOverlay

getBaseContext() is a default method in android.content.ContextWrapper class.

what is the problem here.. any idea???


The question is: In which class do you create a Geocoder object? The getBaseContext() does not work in a class which extends from Overlay, because Overlay is not a child of ContextWrapper.
It exists in your MapActivity, if you use one. The easiest way to solve the issue is to give the Overlay the context as parameter/setter method.

0

精彩评论

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

关注公众号