我有這樣的代碼:以上循環動態數據
entryData = new Entry[] {
new Entry(path1, name1, tag1),
new Entry(path2, name2, tag2),
new Entry(path3, name3, tag3),
new Entry(path4, name4, tag4)
};
的數據給我的列表視圖4項(行)。這工作正常。
但是如果我循環,例如:
for(x=0; x<4; x++){
entryData = new Entry[] { new Entry(pathx, namex, tagx) };
}
我的列表視圖中顯示一個項目(行)只...
我的類代碼:
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;
}
}
任何想法?我只是再次學習它! TIA!
你必須在使用之前初始化數組,並且還建議使用數組列表來添加動態元素 –