Sometimes listView.getChildAt(int index) returns NULL (Android)

后端 未结 4 1683
离开以前
离开以前 2020-12-02 02:06

I have a listView with a custom adapter. When something happens (a click in a child) I do some calculation things and modify the child View. IF some condition has been fulfi

4条回答
  •  伪装坚强ぢ
    2020-12-02 02:34

    If that child is not visible on screen it means there is no View for it. I believe this is your not working case.

    A good practice is to change the data behind your list adapter and call notifyDataSetChanged() on the adapter. This will inform the list the adapter has changed and paint again the views.

    If you really want to manually update the view I guess the only solution is to retain the new values somewhere and wait until the View becomes visible. At that point you have a valid reference and can do the updates.

提交回复
热议问题