我已经拍摄了一个网格并在其中添加了 9 个图像,并单击了我试图在某个页面上导航的任何图像。但我无法在 GridField 管理器上设置侦听器。我尝试了以下代码:
grid.add(bmp1);
grid.add(bmp2);
grid.add(bmp3);
grid.add(bmp4);
grid.add(bmp5);
grid.setChangeListener(new fieldChangeListener());
add(grid);
}
class fieldChangeListener implements FieldChangeListener{
public void fieldChanged(Field field, int arg1) {
// TODO Auto-generated method stub
System.out.println("Inside Method : "+field.getAccessibleContext());
if(field==bmp1){
Dialog.alert("1 is clicked");
}
if(field==bmp2){
Dialog.alert("2 is clicked");
}
if(field==bmp3){
Dialog.alert("3 is clicked");
}
if(field==bmp4){
Dialog.alert("4 is clicked");
}
if(field==bmp5){
Dialog.alert("5 is clicked");
}