Java me LWUIT 1.5如何捕获选项卡单击事件,从服务器获取内容并在所选选项卡中显示?

Java me LWUIT 1.5如何捕获选项卡单击事件,从服务器获取内容并在所选选项卡中显示?,java-me,lwuit,lwuit-tabs,Java Me,Lwuit,Lwuit Tabs,我正在使用LWUIT 1.5选项卡显示通知。我有三个选项卡,我从一个php web服务获取通知。我成功获取了第一个选项卡的通知列表。但对于接下来的两个选项卡,我无法理解应该编写什么代码 检测是否单击了第二个/第三个选项卡。我知道如何将commandListener添加到按钮。commandListener有什么可供选择的Tab 当从服务器接收到新数据时,如何刷新选项卡的内容 私有void showNotificationList(){ } } 私有哈希表[]getNotifications(){

我正在使用LWUIT 1.5选项卡显示通知。我有三个
选项卡
,我从一个php web服务获取通知。我成功获取了第一个
选项卡的通知列表。但对于接下来的两个
选项卡
,我无法理解应该编写什么代码

  • 检测是否单击了第二个/第三个
    选项卡
    。我知道如何将
    commandListener
    添加到
    按钮
    commandListener
    有什么可供选择的
    Tab
  • 当从服务器接收到新数据时,如何刷新
    选项卡的内容

    私有void showNotificationList(){

    }

    }

    私有哈希表[]getNotifications(){ int total=通知的长度; //系统输出打印项次(总计); 哈希表[]数据=新哈希表[总计]; //哈希表[]数据=新哈希表[5]; /数据[0]=新哈希表(); 数据[0]。输入(“名称”、“Shai”); 数据[0]。输入(“姓氏”、“Almog”); 数据[0]。放置(“选定”,布尔值为.TRUE)/

    for(int i=0;i
    }

  • 1) 我遇到了同样的问题,我通过覆盖
    表单的
    keyreased
    而不是
    选项卡来解决它
    在它里面,我检查聚焦的组件,如果它是
    选项卡
    get“Tab.selectedIndex”,则检测我在哪个
    选项卡
    中,并加载适当的数据。 下面是示例代码(在扩展表单的my派生表单中)

    **

    2) 关于刷新数据,我做了一个解决方案,我不知道它是否正确 我获取新数据,创建新的
    列表
    ,然后删除旧数据并附加新数据 调用
    Form.repaint()

    try {
    
        Form f = new Form("Notifications");
        f.setScrollable(false);
        f.setLayout(new BorderLayout());
        final List list = new List(getNotifications()); //gets hashtables - notices
        list.setRenderer(new GenericListCellRenderer(createGenericRendererContainer(), createGenericRendererContainer()));
        list.setSmoothScrolling(true);
        //System.out.println("adding list component to listview");
        list.addActionListener(new ActionListener() {
    
            public void actionPerformed(ActionEvent evt) {
                int i = list.getSelectedIndex();
                noticeDetailsForm(notices[i]);
                //Dialog. show( "title",  notices[i].toString(),  "ok",  "exitt");
            }
        });
        //Container c2 = new Container(new BoxLayout(BoxLayout.Y_AXIS));
        //c2.addComponent(list);
        Tabs tabs = new Tabs(Tabs.TOP);
        tabs.addTab("Recent", list);
        tabs.addTab("Urgent", new Label("urgent goes here"));
        tabs.addTab("Favourites", new Label("favs goes here"));
    
        //f.addComponent(tabs);
        f.addComponent(BorderLayout.CENTER, tabs);
        Command backComm = new Command("Back") {
    
            public void actionPerformed(ActionEvent ev) {
                Dashboard.dbInstance.setUpDashboard();
    
            }
        };
        f.addCommand(backComm);
        //System.out.println("showing lsit form");
        f.show();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    
    private Container createGenericRendererContainer() throws IOException { //System.out.println("container called");
    
    //System.out.println("container called");
    Container c = new Container(new BorderLayout());
    c.setUIID("ListRenderer");
    
    Label xname = new Label("");
    Label description = new Label();
    Label focus = new Label("");
    Container cnt = new Container(new BoxLayout(BoxLayout.Y_AXIS));
    xname.setName("Name");
    xname.getStyle().setBgTransparency(0);
    xname.getStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM));
    //description.setFocusable(true);
    description.setName("Description");
    cnt.addComponent(xname);
    cnt.addComponent(description);
    c.addComponent(BorderLayout.CENTER, cnt);
    Button thumb = new Button(Image.createImage("/res/home-work.png"));
    //Image img = Image.createImage("/res/home-work.png");
    c.addComponent(BorderLayout.WEST, thumb);
    
    return c;
    
    for (int i = 0; i < total; i++) {
        data[i] = new Hashtable();
        //System.out.println(notices[i].getName());
        data[i].put("Name", notices[i].getName());
        data[i].put("Description", notices[i].getDescription());
        data[i].put("Id", Integer.toString(notices[i].getId()));
    }
    
    return data;
    
    public void keyReleased(int keyCode) {
            Component p=this.getFocused();
           String str= p.getClass().getName();
        if(str.toLowerCase().indexOf("radiobutton")!=-1){    // Radiobutton because when u 
      Here do tab specific work                              focus on the 
                                                             tab it returns radiobutton.                                    
                                                             lwuit understands tabs as list   
                                                             of radiobuttons 
                          }**