i am not able to display the detailed form information specific to the title user clicked on form1 Screen,when i click on any itemlist on form1 screen,i am able to display the detail of first item only(in my code int index=myNewsList.getSelectedIndex() returns always 0 as value)
Here my Detailed Code for Rss App:
//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?
Add action listener to the list. It is called only if you click any item of the list. In that action listener, get the selected item and cast it to the News class object because you added News class objects in the list. From that object, get the unique property like news id. Pass it to another screen with the current form object (form1).
With the news id, you can display the related data in another screen. Add back command to it. In the back command, just show the form1 object.
Instead of using
Use the below code