LayoutInflater trong Android làm gì?
LayoutInflater trong Android làm gì?
LayoutInflater chuyển file layout XML thành đối tượng View trong bộ nhớ (inflate).
val view = LayoutInflater.from(context).inflate(R.layout.item_user, parent, false)
// Fragment
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, s: Bundle?): View =
inflater.inflate(R.layout.fragment_home, container, false)
// ViewBinding (thông dụng hơn)
val binding = ItemUserBinding.inflate(LayoutInflater.from(parent.context), parent, false)
attachToRootĐăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.