mirror of
https://github.com/Leo501/CocosCreatorTutorial.git
synced 2026-05-24 01:19:44 +08:00
添加listView中addData的动态加数据
This commit is contained in:
@@ -16,8 +16,14 @@ cc.Class({
|
||||
},
|
||||
|
||||
start() {
|
||||
const adapter = new ListAdapter();
|
||||
adapter.setDataSet([1, 2, 3, 4, 5, 6, 7, 8, 89, 9, 12, 1243, 45, 564, 6756, 876, 7988, 789, 78987, 978, 45, 6732, 423, 42], 'ListItem');
|
||||
this.listView.setAdapter(adapter);
|
||||
}
|
||||
this.adapter = new ListAdapter();
|
||||
this.adapter.setDataSet([1, 2, 3, 4, 5, 6, 7, 8, 89, 9, 12, 1243, 45, 564, 6756, 876, 7988, 789, 78987, 978, 45, 6732, 423, 42], 'ListItem');
|
||||
this.listView.setAdapter(this.adapter);
|
||||
},
|
||||
|
||||
onBtnAdd() {
|
||||
let data = [321, 322, 323, 324];
|
||||
this.adapter.addData(data);
|
||||
this.listView.resetScrollLength();
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user