Hello All,
I am trying to make a List View similar to Androids, in standard processing, and have a skeleton started. But i have no clue on how to code the methods so that i could add and remove the items. Has this been done before? Maybe a library could help me... If anyone has any opinions, please post them...Thanks
- PApplet app = this;
- SideList Sl;
- int ListLocation;
- void setup() {
- size(250, 800);
- ListLocation = 0;
- Sl = new SideList(ListLocation);
- }
- void draw() {
- }
- int ItemTally = 0;
- public class SideList {
- ArrayList Items = new ArrayList();
- int itemHeight = 50;
- int X;
- SideList(int x) {
- X=x;
- Items.add( new SideListItem("Front", "Light Detection", X, Items.size()*(itemHeight+1), itemHeight));
- Items.add( new SideListItem("Front", "Light Detection", X, Items.size()*(itemHeight+1), itemHeight));
- Items.add( new SideListItem("Left", "Light Detection", X, Items.size()*(itemHeight+1), itemHeight));
- app.registerDraw(this);
- }
- void setItemHeight(int i) {
- itemHeight = i;
- }
- void draw() {
- fill(100);
- noStroke();
- rect(X, 0, 250, height);
- for (int i=0; i<Items.size(); i++) {
- SideListItem Item = (SideListItem) Items.get(i);
- Item.display();
- }
- fill(0);
- rect(X, height-40, 250, 40);
- textAlign(LEFT, TOP);
- fill(255);
- textSize(30);
- text(timestampTime(), X+10, height-40);
- }
- }
- public class SideListItem {
- int I, X, Y, height;
- int ID;
- String Location, Info;
- SideListItem(String loc, String info, int x, int y, int h) {
- X=x;
- Y=y;
- height=h;
- Location = loc;
- Info = info;
- println("Built SideList ITEM: "+ I +" @"+X+","+Y );
- }
- void display()
- {
- fill(255);
- noStroke();
- rect(X, Y, 250, height);
- fill(0);
- textSize(14);
- textAlign(LEFT, TOP);
- text(Location, X+2, Y);
- textAlign(RIGHT, TOP);
- textSize(9);
- text(": XX/XX/XX XX:XX:XX", X+250, Y);
- text("Elapsed Time: 32 seconds", X+250, Y+12);
- textAlign(LEFT, TOP);
- textSize(16);
- text(Info, X, Y+30);
- noFill();
- }
- }
- String timestampTime() {
- Calendar now = Calendar.getInstance();
- return String.format("%1$tH:%1$tM:%1$tS", now);
- }
1