BaseAdapter notifyDatasetChanged() called but getView() is never called

前端 未结 4 1153
梦毁少年i
梦毁少年i 2021-01-01 21:58

I have a custom adapter that visualize each row in the list of Orders.

public class OrderRowAdapter extends BaseAdapter implements OnClickListener {
    Ord         


        
4条回答
  •  执念已碎
    2021-01-01 22:44

    If all above answers not working try with invalidateViews()

    ListView.invalidateViews() is used to tell the ListView to invalidate all its child item views (redraw them).

    Note that there not need to be an equal number of views than items. That's because a ListView recycles its item views and moves them around the screen in a smart way while you scroll.

     listView.invalidateViews()
    

    My sample implementation,

                        lvitems.post(new Runnable() {
                            @Override
                            public void run() {
                                lvitems.invalidateViews(); //invalidate old
                                CustomAdapter customAdapter=new CustomAdapter(context, names, images); // load new data
                                customAdapter.notifyDataSetChanged();// call notifydatasetChanged
                            }
                        });
    

    If any mistake in this answer please correct my mistakes.

提交回复
热议问题