在zk中需要给页面的按钮button 添加事件监听,同时弹出修改页面。
但是在监听事件类算是一个内部类。在内部类引用局部变量要求必须是final的,而引用全局变量就不需要。该怎样解决这个问题呢。
主要是在新建类都构造方法中加入外部类的局部变量,然后就可以传给内部类了
String netbar_id=netbar.getNetbar_id();//保存参数
Button detail=new Button();
detail.addEventListener(Events.ON_CLICK, new showEventListener(netbar_id));
class showEventListener implements EventListener{
String id;
public showEventListener(String netbar_id){
this.id=netbar_id;
}
@Override
public void onEvent(Event event) throws Exception {
Div div=new Div();
div.appendChild(new NetbarDetailWin(id));
win.appendChild(div);
}
}