1

I developed an Rss Application using LWUIT Tabs,i want to display Rss Feed Titles and images on my Lwuit Tab screen,but when i run my application i am able to display three List (title with image)items Sucessfully,after that i am facing java.lang.OutOfMemoryError(stack trace incomplete) Eventhough there are list items present?can any one help......thanks...

Here my Code:

public class Process {
     protected XMLMidlet midlet;

     Form form1;
     Image image;
     Tabs tabs;
     private List myNewsList;
    private Vector topnews;
    private Vector topstory;
    private Command cmdExit;
    private Command m_backCommand;
      private List newsList;
        private Form form2;
    Process(XMLMidlet midlet) throws IOException {
           this.midlet=midlet;
           topnews = new Vector();
        topstory = new Vector();
       tabs = new Tabs();
        form1 = new Form();
        form2=new Form();
           try {
            newsList = new List(topnews);
            newsList.setScrollVisible(false);
            newsList.setRenderer(new NewsListCellRenderer());   
         m_backCommand = new Command("Back");
        cmdExit = new Command("EXIT");
           tabs.addTab("Topstory", newsList); 
            form1.addComponent(BorderLayout.CENTER, tabs);                           
}
catch(Exception e){
    e.printStackTrace();
}           }

   public void process() {
       try{
   String url = "http://www.teluguone.com/news/tonefeeds/news/news-1.rss";

       form1.show();
       ParseThread myThread = new ParseThread(this);
       myThread.getXMLFeed(url);

        } catch (Exception e) {

        }

    }
   public void addNews(News newsItem) {

try{
            topnews.addElement(newsItem);
            newsList.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent ae) {

                    List source = (List) ae.getSource();
                    News selectedNewsItem = (News) source.getSelectedItem();
                    if (selectedNewsItem != null) {
                        displayCompleteNewsScreen(selectedNewsItem);

                    }

                }


            });
}
catch(OutOfMemoryError r){

}
        form1.show();


    }


    private void displayCompleteNewsScreen(News detailNews) {

       try{ 
        form2.removeAll();
        form2.repaint();
        form2.addCommand(m_backCommand);
        form2.addCommandListener(new ActionListener() {

            public void actionPerformed(ActionEvent ae) {
                form1.show();
            }
        });

        HTMLComponent com=new HTMLComponent();
        com.setPreferredSize(new Dimension(300,300));
com.setShowImages(false);

       com.setBodyText(detailNews.getDescription());
       form2.addComponent(com);
        //form2.addComponent(big);
        }
       catch(OutOfMemoryError e){

       }
        form2.show();

    }



}
String
  • 3,660
  • 10
  • 43
  • 66

1 Answers1

2

How big are the images? What handset are we talking about here?

I am betting that the images you're getting are not being scaled down before being displayed. I believe there are methods in LWUIT to scale down the size of an image. Remember to dispose of the temp image you create after adding the image to your form.

Ian
  • 691
  • 3
  • 9
  • HI lan Gil,can you check this http://stackoverflow.com/questions/12871421/lwuit-htmlcomponent,if you look at this ,i'm able to display the text but i'm not able to display the image – String Oct 15 '12 at 09:40
  • Afetr i did parsing ,i'm getting the htmltext which contains description as well as image tag(an image as well as description)to display it on my Nokia sdk 3.0 and Nokia sdk 2.0... – String Oct 15 '12 at 09:43
  • Could you tell me how can i Scale the images which are getting from HTMLsString... – String Oct 15 '12 at 09:44
  • What you can try is to separate the image from the others. Create an image based on the src then you can use this [algo](http://willperone.net/Code/codescaling.php). There are other image scaling algo out there though. – Ian Oct 16 '12 at 02:18
  • For Testing Purpose,what i did was, what ever I get Html String from Rss File,I've removed "src" attribute from my String(So Finally there is no question of Image tag)and i tested my application,I'm able to display Description(Pure Text)Successfully ,But it still throwing OutOfMemory Exception.... – String Oct 16 '12 at 06:30
  • and also Uncaught exception: java.util.NoSuchElementException at java.util.Vector.lastElement(Vector.java:456) - com.sun.lwuit.html.HTMLComponent.popContainer(HTMLComponent.java:3667) - com.sun.lwuit.html.HTMLComponent.processTag(HTMLComponent.java:2825) – String Oct 16 '12 at 06:54