【发布时间】:2011-08-18 21:19:48
【问题描述】:
我有一个主 Activity 类,它有一个按钮,我为其分配了一个 OnClickListener:
public class MyMainClass extends Activity {
protected void initWidgets() {
btAddProfile = (Button) findViewById(R.id.btAddProfile);
btAddProfile.setOnClickListener(onAddProfileClick);
}
protected View.OnClickListener onAddProfileClick = new View.OnClickListener() {
public void onClick(View view) {
addHotspot();
}
};
protected void addHotspot(){
//doStuff
}
}
onAddProfileClick 实例是 MyMainClass 的子实例,但它能够在不引用 MyMainClass 的情况下调用 MyMainClass 的 addHotspot() 函数。这怎么可能?
【问题讨论】:
-
仅供参考,这不是 android 特有的现象。
标签: java android namespaces onclick listeners