Android Studio Tutorial - Part 6 (2020 Edition)

Опубликовано: 05 Апрель 2020
на канале: DJ Malone
18,442
220

Let's backtrack a little from the last Android Studio tutorial and display a list of products on the MainActivity screen. First we'll use Kotlin's listOf() helper method to quickly create a list of anything, and for starters, String's. Then we'll see how we can also create a list of Int's, or anything else for that matter. If we mix and match (Int and String) Kotlin will convert the list type into a List of Any.

In Android Studio 3.6 (I finally upgraded!) we'll drag in a TextView to display our list of Products. In MainActivity we'll use Kotlin's forEach helper method to loop through each String, Int or Product individually, appending each String to the TextView.

In the process we'll learn about Data Classes and how to add variables to those types of classes. We'll calculate the total cost and display it in red at the bottom of the screen.

In the next tutorial we'll convert the UI side of the list to a RecyclerView to be more efficient. Using Kotlin's forEach is great, but if we have a list of a lot of data, really the preferred method is to use a RecyclerView. But don't worry we'll use stuff like we learned in this tutorial throughout the series.

So let's connect on LinkedIn and please leave a comment if you have questions! Cheers :)

Connect with me on LinkedIn!   / danielmalone  


Смотрите видео Android Studio Tutorial - Part 6 (2020 Edition) онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь DJ Malone 05 Апрель 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 18,44 раз и оно понравилось 22 людям.