0

我在我的 main 中清除了一个数组列表(sizecheck 说 0),但是当我再次从我的类中添加时,原始数据在新数据之前重新出现,大小检查确认了这一点。有没有办法解决?

澄清一下:我一直在清除,通过 log cmd 确认 arraylist 大小为 0 的大小,重新添加新数据只会增加总数。清除 50-->0,然后添加 50 = 100,清除 100-->0 并再次添加 50,它是 150,等等。

帮我杀了这个僵尸数据!

以下为节录:

ArrayList<Integer> imagearray = new ArrayList<Integer>();
....onCreate....
imagearray.clear(); // confirmed this makes arraylist size = 0
imagearray.addAll(animalclass.getpics(songtolearn)); 
// this last line is dragging all the cleared data back and adds the new data too

它从以下位置拖动数据:

public ArrayList<Integer> getpics(int songnumber) {

switch (songnumber) { 
case 1:
  animalpics.add(1);
  animalpics.add(1);
break;
return animalpics;
4

1 回答 1

0

在动物类中,我需要删除 ArrayList animalpics = new ArrayList(); 我从哪里声明变量并将其放在本地 getpics 命令中。

于 2013-04-14T11:42:47.190 回答