我无法显示特定于在 form1 屏幕上单击的标题用户的详细表单信息,当我单击 form1 屏幕上的任何项目列表时,我只能显示第一项的详细信息(在我的代码中 int index=myNewsList. getSelectedIndex() 总是返回 0 作为值)
这是我的 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?