How can I update a single row in a ListView?

前端 未结 11 2099
时光说笑
时光说笑 2020-11-22 17:07

I have a ListView which displays news items. They contain an image, a title and some text. The image is loaded in a separate thread (with a queue and all) and w

11条回答
  •  囚心锁ツ
    2020-11-22 17:38

    I used the code that provided Erik, works great, but i have a complex custom adapter for my listview and i was confronted with twice implementation of the code that updates the UI. I've tried to get the new view from my adapters getView method(the arraylist that holds the listview data has allready been updated/changed):

    View cell = lvOptim.getChildAt(index - lvOptim.getFirstVisiblePosition());
    if(cell!=null){
        cell = adapter.getView(index, cell, lvOptim); //public View getView(final int position, View convertView, ViewGroup parent)
        cell.startAnimation(animationLeftIn());
    }
    

    It's working well, but i dont know if this is a good practice. So i don't need to implement the code that updates the list item two times.

提交回复
热议问题