Reputation: 301
I am getting this error in my program after adding few label and editfield, then passing the saved value to the other class.
It gave me StackOverFlow error when I pressed on the particular button, yet the class did not implements any Hashtable elements.
LongHashtable.get(long) line: 454
And this is the class I mentioned about.
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);
}
This it the class from where the String value will be passed.
May I know how to solve this issue?
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());
}
}}
Thanks!
Upvotes: 0
Views: 561
Reputation:
Seems that you run out of memory/stack resources on your device at the runtime.
When you press a button you compose (a quite complex) screen and push it on the screen stack. And when a button on the new screen is pressed, then you produce new object and push this new screen to the stack.
This is not a good approach at all. Instead of that consider having one screen and update its content via change event. Do not produce new screens, update content of the existing one.
Upvotes: 1