我正在将数据从一个数组列表分配给另一个数组。并尝试将其添加到新的数组列表中。 但我只能看到一个数据存储在数组列表中。
public ArrayList<DataCache> getData()
{
StoreData data = new StoreData(this);
if(data != null && data.getFeedValue() == 1 && contentOf !=null)
{
ArrayList<DataCache> cacheOf = new ArrayList<DataCache>();
ArrayList<DataCache> cache = new ArrayList<DataCache>();
System.out.println("Size of ContentOf"+contentOf.size());
for (int i=0;i<contentOf.size();i++)
{
System.out.println("Value of ContentOf"+contentOf.get(i).mFeed);
System.out.println("Value of ContentOf Data"+contentOf.get(i).mFeed.getData());
cache = contentOf.get(i).mFeed.getData();
if (cache != null && cache.size() > i)
{
cacheOf.add(cache.get(i));
System.out.println("Cache value of "+i+ " is "+ cache.get(i));
}
}
return cacheOf;
}
}
日志:
-03 15:56:34.980: I/System.out(14202): Size of ContentOf3
02-03 15:56:34.990: I/System.out(14202): Value of ContentOfcom.ap.philly.utils.PDCConst$PDCFeed@40a4cc00
02-03 15:56:34.990: I/System.out(14202): Value of ContentOf Data[com.philly.prosportsframework.utils.DataCache@40a7ade0]
02-03 15:56:34.990: I/System.out(14202): Cache value of 0 is com.philly.prosportsframework.utils.DataCache@40a7ade0
02-03 15:56:34.990: I/System.out(14202): Value of ContentOfcom.ap.philly.utils.PDCConst$PDCFeed@408a3490
02-03 15:56:34.990: I/System.out(14202): Value of ContentOf Data[com.philly.prosportsframework.utils.DataCache@40a0d058]
02-03 15:56:34.990: I/System.out(14202): Value of ContentOfcom.ap.philly.utils.PDCConst$PDCFeed@408a3d50
02-03 15:56:34.990: I/System.out(14202): Value of ContentOf Data[com.philly.prosportsframework.utils.DataCache@410dbd78]
02-03 15:56:34.990: I/System.out(14202): %%%%%% SIZE OF CACHE IS 1
答案 0 :(得分:1)
为什么不使用Arraylist
方法addAll()
?
cache.addAll(cacheOf);