現(xiàn)象
總是加載數(shù)據(jù)的總集合大小為0阔加,后來經(jīng)過斷點(diǎn)調(diào)試才發(fā)現(xiàn)原因:i 和 j 不能混淆
for (int i =0; i < songsTypes.size(); i++)
{SongsType songsType = songsTypes.get(i);int mCurrentId = songsType.getId();
MusicSortItem musicSortItem = new MusicSortItem();musicSortItem.setmTitle(songsType.getType_name());
musicSortItem.setType(true);allItems.add(musicSortItem);
for (int j =0; j < songSheetBeanList.size();j++)
{SongSheetBean ssb = songSheetBeanList.get(j);if (mCurrentId == ssb.getType_id()
{? ? ?
? MusicSortItem musicSortItemSub = new MusicSortItem();
musicSortItemSub.setmTitle(ssb.getSSheet());
musicSortItemSub.setType(false);musicSortItemSub.setShid(ssb.getShid());
allItems.add(musicSortItemSub);
}
}
}
需要注意
嵌套循環(huán)外層和層的循環(huán),不能混淆顛倒位置