关于android线程的一个小问题,菜鸟求助
黄舟
黄舟 2017-04-17 17:26:37
0
1
537

我这个线程是放在Listview的适配器里的,获取到网络图片的url集合(pics),我遍历出其中的url进行Base64编码之后再放入另外一个集合(pathlist泛型为List<String>)里,为什么会出现我得到的pathlist.get(position).size 不等于pics.size呢? 是因为线程造成的吗?本人新手,希望各位大神指点

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
PHPzhong

Remove the thread. Still not equal.
I don’t understand why we need to double-nest List<List<String>>.
Each loop re-obtains a List<String> instance from pathList. The size() of this instance seems to have nothing to do with pics.size().
With the addition of threads, it is no longer executed sequentially from beginning to end. Maybe the for loop outside the thread has ended. The code in the thread just starts executing.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template