Search code examples
androidgridviewnotifydatasetchanged

Android, can i update Grid view without using notifyDataSetChanged?


Android App. has custom product GridView (ProductImage/ProductPrice/ProductDiscount).. every time user scroll down the App. fetch new products and updating GridView using notifyDataSetChanged(). - the problem is when updating GridView with new products, the scroll return to top of GridView which force user to scroll down again from the beginning of the GridView. Is there anyway can use to update GridView rather notifyDataSetChanged to stop updating the whole GridView?


Solution

  • I would suggest using RecyclerView like Vogella is showing here

    than you can add items and use on of those

        RecyclerView.Adapter.notifyItemChanged(int position);
        RecyclerView.Adapter.notifyItemInserted(int position);
        RecyclerView.Adapter.notifyItemRangeInserted(int positionStart, int positionEnd);
        RecyclerView.Adapter.notifyItemRangeChanged(int positionStart, int positionEnd);