• 로그인 함 해보끄나?

  • Sarangnamu.net June 17, 2003
    Home Login Profile Study Open Project Q&A Google Code
    list adapter
    Last Modify : 13 March, 2020(12:47)
    https://github.com/jungilhan/scratchpad-jetpack/blob/master/app/src/main/java/com/scratchpad/jetpack/ListAdapterActivity.kt 꽤나 오랬동안 사용 해 오던 기본 어뎁터를 떠나 보내고 이걸 사용하는데 좋아 보임 class MyListAdapter( ) : ListAdapter<Item, ItemViewHolder>(DIFF_CALLBACK) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProductItemViewHolder { // TOOD } override fun onBindViewHolder(holder: ProductItemViewHolder, position: Int) { // TODO } fun updateItems(items: List<ProductItem>) { submitList(items) } companion object { private val DIFF_CALLBACK = object: DiffUtil.ItemCallback<Item>() { override fun areItemsTheSame(oldItem: Item, newItem: Item): Boolean = oldItem.id == newItem.id override fun areContentsTheSame(oldItem: Item, newItem: Item): Boolean = oldItem.content == newItem.content } } }

    Comment


    입력하3 1586415349



    Locations of visitors to this page