JVM 104:Blackberry Simulator中的堆栈溢出错误

时间:2012-03-19 15:52:06

标签: android blackberry stack-overflow

添加少量标签和编辑字段后,我在程序中收到此错误,然后将保存的值传递给其他类。

当我按下特定按钮时,它给了我StackOverFlow错误,但是该类没有实现任何Hashtable元素。

  

LongHashtable.get(long)行:454

这是我提到的课程。

public final class RSSMainScreen extends MainScreen implements FieldChangeListener{

RSSFeedList rfl = new RSSFeedList ();

String rssUrl1 = "http://kompas.feedsportal.com/c/33612/f/589626/index.rss";
String rssUrl2 = "http://feeds.gawker.com/lifehacker/full";
String rssUrl3 = rfl.x ;

ButtonField viewRSSButton = new ButtonField("Refresh");
ButtonField editRSSButton = new ButtonField("Settings");

DefaultHandler dh = new DefaultHandler();

public RSSMainScreen()
{       

    // Set the displayed title of the screen       
    HorizontalFieldManager hfm = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER);

    setTitle("");

    viewRSSButton.setChangeListener(this);
    editRSSButton.setChangeListener(this);

    String[][] urlData1 = dh.getURLFromRSS(rssUrl1);
    String[][] urlData2 = dh.getURLFromRSS(rssUrl2);
    String[][] urlData3 = dh.getURLFromRSS(rssUrl3);


    add(new LabelField("KOMPAS"));
    add(new SeparatorField());

    for (int i = 0; i < urlData1.length; i++) 
    {
        String title = urlData1[0][i];
        String url = urlData1[1][i];
        add(new LinkLabel(title, url));
        add(new SeparatorField());
    }

    add(new LabelField("LIFEHACKER"));
    add(new SeparatorField());

    for (int i = 0; i < urlData2.length; i++) 
    {
        String title = urlData2[0][i];
        String url = urlData2[1][i];
        add(new LinkLabel(title, url));
        add(new SeparatorField());
    }

    add(new LabelField("CUSTOM"));
    add(new SeparatorField());

    for (int i = 0; i < urlData3.length; i++) 
    {
        String title = urlData3[0][i];
        String url = urlData3[1][i];
        add(new LinkLabel(title, url));
        add(new SeparatorField());
    }

    hfm.add(viewRSSButton);
    hfm.add(editRSSButton);

    this.add(hfm);
}

这是传递String值的类。

我可以知道如何解决这个问题吗?

public class RSSFeedList extends MainScreen implements FieldChangeListener {
RSSMainScreen rms = new RSSMainScreen();

ButtonField backButton = new ButtonField("Cancel and Back");
ButtonField saveButton = new ButtonField("Save");
BasicEditField thirdURL = new BasicEditField();

String x  = "";

protected RSSFeedList()
{
    HorizontalFieldManager hfm = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER);

    backButton.setChangeListener(this);
    saveButton.setChangeListener(this);

    LabelField firstURLLabel = new LabelField("First RSS");
    LabelField firstURL = new LabelField(rms.rssUrl1);

    LabelField secondURLLabel = new LabelField("Second RSS");
    LabelField secondURL = new LabelField(rms.rssUrl2);

    LabelField thirdURLLabel = new LabelField("Third RSS (Editable)");

    hfm.add(firstURLLabel);
    hfm.add(new SeparatorField());
    hfm.add(firstURL);
    hfm.add(new SeparatorField());
    hfm.add(secondURLLabel);
    hfm.add(new SeparatorField());
    hfm.add(secondURL);
    hfm.add(new SeparatorField());
    hfm.add(thirdURLLabel);
    hfm.add(new SeparatorField());
    hfm.add(thirdURL);
    hfm.add(new SeparatorField());

    hfm.add(backButton);
    hfm.add(saveButton);

    this.add(hfm);
}

public void fieldChanged(Field field, int context) 
{
    if(field == backButton)
    {
        //screen = new RSSMainScreen();
    }
    else if(field == saveButton)
    {
        x = thirdURL.getText().toString();
        //screen = new RSSMainScreen();
        UiApplication.getUiApplication().pushScreen(new RSSMainScreen());
    }

}}

谢谢!

1 个答案:

答案 0 :(得分:1)

似乎您在运行时在设备上耗尽了内存/堆栈资源。

当你按下一个按钮时,你会构图(一个非常复杂的)屏幕并将其推到屏幕堆栈上。 当按下新屏幕上的按钮时,您将生成新对象并将此新屏幕推送到堆栈。

这根本不是一个好方法。而不是考虑使用一个屏幕并通过更改事件更新其内容。不要生成新屏幕,更新现有屏幕的内容。