To Develope an Rss Reader Application using LWUIT , we can use the below Code:
RssMidlet:
import com.sun.lwuit.*;
import com.sun.lwuit.animations.Transition3D;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import java.util.Vector;
import javax.microedition.midlet.*;
public class RssMidlet extends MIDlet implements ActionListener {
private List rssFeedList;
private Vector rssFeed;
private Image image;
private Form form1;
public RssMidlet() {
Display.init(this);
rssFeed = new Vector();
form1 = new Form();
form1.setFocus(true);
form1.addCommandListener(this);
form1.setScrollableY(true);
form1.setTransitionInAnimator(Transition3D.createRotation(250, true));
//Initialize a List Object with Vector ref rssFeed
rssFeedList = new List(rssFeed);
rssFeedList.setRenderer(new NewsListCellRenderer());
rssFeedList.setFixedSelection(List.FIXED_NONE);
rssFeedList.setItemGap(0);
form1.addComponent(rssFeedList);
}
public void startApp() {
String url = "Your Input Rss File Here";
ParseThread myThread = new ParseThread(this);
//this will start the second thread
myThread.getXMLFeed(url);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void addNews(RssModel newsItem) {
rssFeed.addElement(newsItem);
form1.show();
}
}
}
You can create a NewsListCellRenderer class by Referring this Example LWUIT Blog ContactsRenderer
Example