【发布时间】:2011-08-29 02:59:05
【问题描述】:
这是我的代码:
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不起作用? -
我的心理调试技能告诉我
gotLocation是一个异步回调,但您希望它同步运行。 -
@Bruno:错了。内部类可以写入所有字段(与本地相反)。他们得到了对父母
this的引用。
标签: java class anonymous-class