Android,我可以在不使用 notifyDataSetChanged 的情况下更新网格视图吗?
Android, can i update Grid view without using notifyDataSetChanged?
Android 应用程序。有自定义产品 GridView (ProductImage/ProductPrice/ProductDiscount).. 每次用户向下滚动应用程序。使用 notifyDataSetChanged() 获取新产品并更新 GridView。 -
问题是在用新产品更新 GridView 时,滚动 return 到 GridView 的顶部,这迫使用户再次从 GridView 的开头向下滚动。 是否可以使用 notifyDataSetChanged 来更新 GridView 而不是停止更新整个 GridView?
我建议像 Vogella 展示的那样使用 RecyclerView here
你可以添加项目并使用其中的项目
RecyclerView.Adapter.notifyItemChanged(int position);
RecyclerView.Adapter.notifyItemInserted(int position);
RecyclerView.Adapter.notifyItemRangeInserted(int positionStart, int positionEnd);
RecyclerView.Adapter.notifyItemRangeChanged(int positionStart, int positionEnd);
Android 应用程序。有自定义产品 GridView (ProductImage/ProductPrice/ProductDiscount).. 每次用户向下滚动应用程序。使用 notifyDataSetChanged() 获取新产品并更新 GridView。 - 问题是在用新产品更新 GridView 时,滚动 return 到 GridView 的顶部,这迫使用户再次从 GridView 的开头向下滚动。 是否可以使用 notifyDataSetChanged 来更新 GridView 而不是停止更新整个 GridView?
我建议像 Vogella 展示的那样使用 RecyclerView here
你可以添加项目并使用其中的项目
RecyclerView.Adapter.notifyItemChanged(int position);
RecyclerView.Adapter.notifyItemInserted(int position);
RecyclerView.Adapter.notifyItemRangeInserted(int positionStart, int positionEnd);
RecyclerView.Adapter.notifyItemRangeChanged(int positionStart, int positionEnd);