I have this code:
entryData = new Entry[] {
new Entry( path1, name1, tag1 ),
new Entry( path2, name2, tag2 ),
new Entry( path3, name3, tag3 ),
new Entry( path4, name4, tag4 )
};
The data above gives my list view 4 items (rows). That works fine.
But if I loop, for example:
for(x=0; x<4; x++){
entryData = new Entry[] { new Entry( pathx, namex, tagx ) };
}
My list view shows one item (row) only…
My class code is:
public class Entry {
public String icon;
public String title;
public String tag;
public Entry() {
super();
}
public Entry(String icon, String title, String tag) {
super();
this.icon = icon;
this.title = title;
this.tag = tag;
}
}
Any ideas? I’m just learning it again! TIA!!!
The array must be defined before the loop. Each iteration should only add an element to the array:
If you don’t know the size of the array in advance, then use a List instead, which grows dynamically:
Also, please respect the Java naming conventions.