我使用LWUIT 1.5標籤顯示通知。我有三個Tabs
,我從php web服務中獲取通知。我成功提取了第一個Tab
的通知列表。但是對於接下來的兩個Tabs
,我不理解,我應該寫什麼代碼LWUIT 1.5如何捕獲標籤的點擊事件,獲取來自服務器的內容,它顯示選中的標籤?
- 檢測第二/第三
Tab
被點擊。我知道如何將commandListener
添加到Button
。什麼commandListener
是有Tab
選擇? 當從服務器接收新的數據如何刷新
Tab
的內容?私人無效showNotificationList(){
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;
}
私人哈希表[] getNotifications(){ INT總= notices.length; //System.out.println(total); Hashtable [] data = new Hashtable [total]; // Hashtable [] data = new Hashtable [5]; /數據[0] =新的Hashtable(); data [0] .put(「Name」,「Shai」); data [0] .put(「Surname」,「Almog」); data [0] .put(「Selected」,Boolean.TRUE);/
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;
}