本文介绍了LWUIT未捕获的异常:java.lang.OutOfMemoryError(堆栈跟踪不完全)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我开发使用LWUIT的标签,我想显示我的LWUIT选项卡屏幕上的RSS Feed标题和图像的RSS应用程序,但是当我运行我的应用程序,我能够显示多达三个列表项成功地(含图片标题),之后我面临的 java.lang.OutOfMemoryError(堆栈跟踪不完整) Eventhough有列表项present?任何一个可以帮助......谢谢......

下面我code:

 公共类流程{
     保护XMLMidlet MIDlet的;     窗体Form1;
     形象画像;
     选项​​卡标签;
     私有列表myNewsList;
    私人向量的TopNews;
    私人矢量topstory;
    私人命令cmdExit;
    私人命令m_backCommand;
      私有列表新闻列表;
        私人表格窗口2;
    流程(XMLMidlet的MIDlet)抛出IOException
           this.midlet = MIDlet的;
           的TopNews =新的向量();
        topstory =新的向量();
       标签=新的选项卡();
        form1的=新表();
        窗口2 =新表();
           尝试{
            新闻列表=新名单(的TopNews);
            newsList.setScrollVisible(假);
            newsList.setRenderer(新NewsListCellRenderer());
         m_backCommand =新指令(返回);
        cmdExit =新指令(EXIT);
           tabs.addTab(Topstory,新闻列表);
            form1.addComponent(BorderLayout.CENTER,制表符);
}
赶上(例外五){
    e.printStackTrace();
}}   公共无效过程(){
       尝试{
   字符串URL =htt​​p://www.teluguone.com/news/tonefeeds/news/news-1.rss;       form1.show();
       ParseThread MyThread的=新ParseThread(本);
       myThread.getXMLFeed(URL);        }赶上(例外五){        }    }
   公共无效addNews(新闻newsItem){尝试{
            topnews.addElement(newsItem);
            newsList.addActionListener(新的ActionListener(){                公共无效的actionPerformed(ActionEvent的AE){                    列表源=(列表)ae.getSource();
                    新闻selectedNewsItem =(新闻)source.getSelectedItem();
                    如果(selectedNewsItem!= NULL){
                        displayCompleteNewsScreen(selectedNewsItem);                    }                }
            });
}
赶上(的OutOfMemoryError R){}
        form1.show();
    }
    私人无效displayCompleteNewsScreen(新闻detailNews){       尝试{
        form2.removeAll();
        form2.repaint();
        form2.addCommand(m_backCommand);
        form2.addCommandListener(新的ActionListener(){            公共无效的actionPerformed(ActionEvent的AE){
                form1.show();
            }
        });        HTMLComponent COM =新HTMLComponent();
        COM.SET preferredSize(新尺寸(300,300));
com.setShowImages(假);       com.setBodyText(detailNews.getDescription());
       form2.addComponent(COM);
        //form2.addComponent(big);
        }
       赶上(OutOfMemoryError异常五){       }
        form2.show();    }}


解决方案

有多大的图像?我们谈论这里什么手机?

我打赌你得到的图像没有被缩小显示之前。相信有在LWUIT方法来缩小图像的尺寸。记住图像添加到您的表单后处置创建临时的形象。

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();

    }



}
解决方案

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.

这篇关于LWUIT未捕获的异常:java.lang.OutOfMemoryError(堆栈跟踪不完全)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 22:33