search

Home  >  Q&A  >  body text

关于android线程的一个小问题,菜鸟求助

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

黄舟黄舟2772 days ago542

reply all(1)I'll reply

  • PHPz

    PHPz2017-04-17 17:28:37

    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.

    reply
    0
  • Cancelreply