这里是我的代码:如何将匿名类方法参数返回到原始实例化类?
public void pollLocation()
{
myLocation.getLocation(this, new LocationResult()
{
public void gotLocation(Location location)
{
//I want to assign Location object from here...
}
});
}
private Location lastLocation; //...to here.
这可能吗?
'lastLocation = something'不起作用? – Thilo
我的心理调试技巧告诉我'gotLocation'是一个异步回调,但你期望它同步运行。 – SLaks
@布鲁诺:错了。内部类可以写入所有字段(而不是本地人)。他们得到了父母的“this”的参考。 – SLaks