Skip to content

Instantly share code, notes, and snippets.

@igo211
Last active October 23, 2015 21:41
Show Gist options
  • Save igo211/c09b6d721ce70b8572ab to your computer and use it in GitHub Desktop.
Save igo211/c09b6d721ce70b8572ab to your computer and use it in GitHub Desktop.
Main class start method for both Codenameone issues: #1416 & #1417
public void start()
{
if (current != null)
{
current.show();
return;
}
Form hi = new Form("Basic memory leakage test");
Container mainContainer = hi.getContentPane();
BorderLayout layout = new BorderLayout();
mainContainer.setLayout(layout);
mainContainer.setScrollableX(false);
mainContainer.setScrollableY(false);
mainContainer.setTensileDragEnabled(false);
mainContainer.setAlwaysTensile(false);
mainContainer.addComponent(BorderLayout.CENTER, new VertIC());
hi.show();
}
package com.whoztop.ictest;
import com.codename1.ui.Component;
import com.codename1.ui.InfiniteContainer;
import com.codename1.ui.Label;
public class VertIC extends InfiniteContainer
{
private static final int ITEMS_IN_ONE_GULP = 1000;
public VertIC()
{
super(ITEMS_IN_ONE_GULP);
}
public Component[] fetchComponents(int index, int amount)
{
if (index > (ITEMS_IN_ONE_GULP - 1))
{
return null;
}
Component[] comps = new Component[amount];
for (int i=0; i<amount; i++)
{
int cmpCnt = index + i;
String lblTxt = "My index is: " + cmpCnt;
Label lbl = new Label(lblTxt);
lbl.setName(lblTxt);
comps[i] = lbl;
}
return comps;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment