0

How to obtain an object data or list data from pagination 3

Good evening everyone, I have a question about how to get a list/object data from a pagination data response. In my case, I want to insert a value of an object into the data obtained from pagination, because when I try to use the index number .get(1) or [1], it doesn't work. Also, when trying to do a snapshot like this: private fun showHeadlineItemFirst(articlesItem: List<ArticlesItem>?) { binding.headlineItemFirst.imgHeadline.load(articlesItem?.get(1)?.urlToImage) binding.headlineItemFirst.titleHeadlineTxt.text = articlesItem?.get(1)?.title binding.headlineItemFirst.mediaPublishTxt.text = articlesItem?.get(1)?.source?.name binding.headlineItemFirst.tanggalPublishTxt.text = articlesItem?.get(1)?.publishedAt } private fun getHeadlineNews() { showProgressBar() homeViewModel.headlineNewsData.observe(viewLifecycleOwner) { response -> hideProgressBar() newsAdapter.submitData(lifecycle, response) } } The application experiences a force close. Please help.

13th May 2023, 6:52 PM
T1mun
T1mun - avatar
1 Odpowiedź