if (Geocoder.isPresent()) {
geocoder = new Geocoder(MapActivity.this.getactivity,Locale.getDefault());这是在doitbackground of asynctask内部。它是地图活性的inner class。
但我不能这么做。错误是:
mapactivity not enclosing class当我做这个的时候。
上面写着
in geocoder can not be applied context"The constructor Geocoder(Context, Locale) is undefined"?
Error: The constructor Geocoder (Context, Locale) is undefined
这些都没用,因为我在内科学课上。我不能使用构造函数来初始化上下文吗?
同时,将内部类名作为第一个参数也不起作用。
错误:
no suitable constructor found for Geocoder(RetrieveFeedTask,Locale)
constructor Geocoder.Geocoder(Context) is not applicable
(actual and formal argument lists differ in length)
constructor Geocoder.Geocoder(Context,Locale) is not applicable
(actual argument RetrieveFeedTask cannot be converted to Context by method invocation conversion)发布于 2015-12-10 18:41:54
在活动顶部附近声明一个上下文变量,并获取上下文:
Context context = YourActivity.getApplicationContext();然后,将上下文变量用于Geo编码器:
if (Geocoder.isPresent()) {
geocoder = new Geocoder(context, Locale.getDefault());https://stackoverflow.com/questions/34207942
复制相似问题