1

我使用 LWUIT 选项卡开发了一个 Rss 应用程序,我想在我的 Lwuit 选项卡屏幕上显示 Rss 提要标题和图像,但是当我运行我的应用程序时,我能够成功显示三个列表(带图像的标题)项目,之后我面临java.lang.OutOfMemoryError(堆栈跟踪不完整) 即使存在列表项?任何人都可以帮助......谢谢......

这是我的代码:

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

    }



}
4

1 回答 1

2

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

我敢打赌,您获得的图像在显示之前不会按比例缩小。我相信 LWUIT 中有一些方法可以缩小图像的大小。请记住在将图像添加到表单后处理您创建的临时图像。

于 2012-10-15T09:19:54.073 回答