У нас вы можете посмотреть бесплатно Room + ViewModel + LiveData + RecyclerView (MVVM) Part 9 - EDIT NOTES ON ITEM CLICK - Android или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
In part 9 of the Architecture Components tutorial, we will implement our update functionality. For this we first create an OnItemClickListener interface in our RecyclerView.Adapter, together with an onItemClick method, which we use to forward the clicked note to the listener that implements this interface. We catch the click on the itemView in our ViewHolder class, get it's position with getAdapterPosition and compare it to RecyclerView.NO_POSITION to make sure that it is still valid. We can either let our MainActivity implement this OnItemClickListener interface, or use an anonymous inner class. By overriding onItemClick, we can then handle the RecyclerView click in our activity. We forward the data of the clicked note as intent extras to the same activity that is also responsible for creating new note entries with startActivityForResult, but additionaly we also send the clicked note's unique ID, because Room needs the primary key to figure out which entry in the entity's table it is supposed to update. In this activity we populate our EditText fields and NumberPicker with the values we sent over, so the user can modify them. When he clicks the save menu icon, we finish the activity, send all the data back to the MainActivity over the resultIntent, and update the note over our ViewModel in the onActivityResult callback of our MainActivity. As usual, all changes apply to our RecyclerView adapter immediately, because our MainActivity observes LiveData. Watch the whole playlist: • Плейлист Example code for this part: https://gist.github.com/codinginflow/... ____________________ 💻 Find the BEST programming tutorials on TutHub: https://tuthub.io ⭐ Get my MVVM Caching Course now: https://codinginflow.com/caching ❗ Subscribe to the channel: / codinginflo. . 📨 Subscribe to the Coding in Flow newsletter: https://codinginflow.com/newsletter ❓ Join our free developer community: / discord 📣 Follow Coding in Flow on other sites: Facebook: / codinginflow Instagram: / codinginflow TikTok: / codinginflow Twitter: / codinginflow Github: https://github.com/codinginflow 💰 Business requests, sponsoring, etc.: info@codinginflow.com