我無法顯示詳細的表單信息,特定於在form1屏幕上點擊的標題用戶,當我點擊form1屏幕上的任何項目列表時,我只能顯示第一個項目的細節(在我的代碼中int index = myNewsList.getSelectedIndex()始終爲0作爲返回值)如何識別lwuit表單屏幕中的列表項?
這裏我詳細的RSS應用程序代碼:
//method called by the parsing thread
public void addNews(News newsItem) {
newsVector.addElement(newsItem);//initialsed list with vector
myNewsList = new List(newsVector);
myNewsList.setListCellRenderer(new NewsListCellRenderer());
form1.addComponent(myNewsList);
form1.show();
myNewsList.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
int selectedIndex = myNewsList.getSelectedIndex();
if(selectedIndex != -1){
newsItem1 = (News)news.elementAt(selectedIndex);
Label l=new Label();
l.setText(newsItem1.getPubDate());
Form detailedForm=new Form();
detailedForm.addCommand(m_backCommand);
detailedForm.addCommandListener(this);
detailedForm.addComponent(l);
detailedForm.show();
}
}
});
}
Can you help?
斐伊川卡萊的,我已經改變了我的代碼,它是好的幹活....在這裏我的代碼... public void actionPerformed(ActionEvent ae){List source =(List)ae.getSource(); 嘗試{ News selectedNewsItem =(News)source.getSelectedItem(); System.out.println(「selectedIndex」+ selectedNewsItem.getDescription()); if(selectedNewsItem!= null){displayCompleteNewsScreen(selectedNewsItem); – String 2012-08-08 05:30:40