google-developer-training / android-basics-kotlin-affirmations-app-solution Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-lists#3
In which task and step of the codelab can this issue be found?
While loops
Describe the problem
In the sentence in a Note: "There are equivalent operators for minus (-=) , multiplication (*=) and division (=)." it seems that the "=" should be "/=".
Steps to reproduce?
As stated above.
Versions
Not applicable.
Additional information
Nil.
URL of codelab
In which task and step of the codelab can this issue be found?
Describe the problem
in the Kotlin playground the results were not displayed
Steps to reproduce?
Versions
What version of Android Studio are you using?
Additional information
Include screenshots if they would be useful in clarifying the problem.
Use RecyclerView to display a scrollable list >> Before you begin
Just a grammatical error
Steps to reproduce?
Additional information
The error reads "How to use organize your code into packages" instead of "How to organize your code into packages"
first issue
styling the textView inside the list_item.xml
when I added the styling line:
android:textAppearance="?attr/textAppearanceHeadline6"
the text appeared small and not at all styled the wanted way.
I had to "Invalidate caches / restart" in order to get the style working.
second issue
use cards
when I added the card view and tried to run, my app crashed. I've ran debug with the logcat and saw:
Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).
then, with the help of stackoverflow, i've added the following line to the materialcardview xml:
android:theme="@style/Theme.MaterialComponents.Light"
and then my app worked and looked as it should.
my android studio version: 4.0.1
In which task and step of the codelab can this issue be found?
Course: Android Basics in Kotlin
Unit 2: Layouts
Sub Unit: Scrollable lists
Codelab Name: Use RecyclerView to display a scrollable list
Codelab Section : 5. Solution code
Describe the problem
In the file "affirmations/adapter/ItemAdapter.kt" there is an error on line no 44, holder.textView.text = context.resources.getString(item.stringResourceId)
Instead of stringResourceId in last part, we have to correct it with stringResourceID, Because in file "affirmations/model/Affirmation.kt" we had declared class variable "stringResourceID" as a parameter.
So, it creates an error because of the letter 'd', to solve the error just replace "stringResourceId" with "stringResourceID" at the line number 44 in file "affirmations/adapter/ItemAdapter.kt".
Or
Replace "stringResourceID" with "stringResourceId" at the line number 3 in file "affirmations/model/Affirmation.kt".
Steps to reproduce?
Versions
What version of Android Studio are you using?
Version 4.2.1
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
In which task and step of the codelab can this issue be found?
Kotlin course - Mutablelist- list of orders
Describe the problem
unresolved reference: addItem
unresolved reference: addItem
Steps to reproduce?
Order(5)
.addItem(Noodles())
.addItem(Noodles())
.addItem(Vegetables("Spinach")))
for (order in ordersList) {
order.print()
println()
}
}
Versions
What version of Android Studio are you using?
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
Step 5. Copy the following into the new themes.xml file (in the values-night directory).
Describe the problem
@color/status_bar_night
Missing color item in colors.xml
Versions
Android Studio 4.0.1
Build #AI-193.6911.18.40.6626763, built on June 25, 2020
Runtime version: 1.8.0_242-release-1644-b3-6222593 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.4.0-48-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 2014M
Cores: 4
Registry: ide.new.welcome.screen.force=true
Non-Bundled Plugins: Dart, org.jetbrains.kotlin, com.google.services.firebase, com.intellij.marketplace, com.thoughtworks.gauge, io.flutter, org.intellij.plugins.markdown
Additional information
I know at this stage it can be ignored. But it's better to add in codelab.
URL of codelab
In which task and step of the codelab can this issue be found?
6
Describe the problem
After applying the MaterialCardView, the displayed image doesn't correspond to the card version. In fact the same image, the one prior to the change, is displayed twice.
Steps to reproduce?
Versions
What version of Android Studio are you using?
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
Step 5 and ^
Describe the problem
Order #3
Noodles: $10
Vegetables Carrots, Beans, Celery: $5
Total: $15
(Total should have been 10 + 5+5+5 = $25 as the there are three vegetables costing $5 each not $5 for total)_****
Order #4
Noodles: $10
Vegetables Cabbage, Onion: $5
Total: $15
(Total should have been 10 + 5+5 = $20 as the there are three vegetables costing $5 each not $5 for total)_****
Order #5
Noodles: $10
Noodles: $10
Vegetables Spinach: $5
Total: $25
Steps to reproduce?
Versions
What version of Android Studio are you using?
Additional information
Include screenshots if they would be useful in clarifying the problem.
This is not a problem, but rather my observation and question.
I created two files with widgets of different names, but the same content, and when the findViewById (R.id.item_title) method is called, the program gets an item from the file created earlier and everything works. If I change @ + id / item_title to @ + id / items _title in an earlier file, then the program stops working, although there is another file with the exact same item and the name @ + id / item_title. The question is how to identify such an error? How to view the file where all id's have been added? Or how to run a full index rewrite? How to see where R.id.item_title comes from because there is no explicit reference to the xml file?
If I asked a stupid question, then I ask you to forgive me, I'm just learning
In which task and step of the codelab can this issue be found?
This task is so long without any test that I do not know from where the problem comes
There is no means of debugging proposed and the technic is rather complex to display a simple litst !! (rather tricky) not very pedagogic to incite to continue training
Describe the problem
The display of the list is only one item !
"I am strong"
Steps to reproduce?
Versions
What version of Android Studio are you using?
brand new 4.2 with Koltin 1.5
Additional information
Include screenshots if they would be useful in clarifying the problem.
This is a confusing problem statement and solution.
It conflates principles of generic lists, containment, and object orientation.
For example the Vegetables class has toppings, but it seems like Vegetables should be toppings for Noodles.
I suspect using the Order class in real life would lead to a confusing jumble of items given to the user.
Of course, this is just an example for teaching, but the cognitive dissonance makes it harder to learn.
It could be argued to be useful in preparing developers for an arbitrary real world of bad specifiers, but was that really your intent?
I found myself going back over and over to try to decipher things that should be fairly simple.
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-display-list-cards
In which task and step of the codelab can this issue be found?
Use cards
Describe the problem
020-10-13 17:28:41.611 11073-11073/com.example.affirmations E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.affirmations, PID: 11073
android.view.InflateException: Binary XML file line #2 in com.example.affirmations:layout/list_item: Binary XML file line #2 in com.example.affirmations:layout/list_item: Error inflating class com.google.android.material.card.MaterialCardView
Caused by: android.view.InflateException: Binary XML file line #2 in com.example.affirmations:layout/list_item: Error inflating class com.google.android.material.card.MaterialCardView
Caused by: java.lang.reflect.InvocationTargetException
Steps to reproduce?
Versions
What version of Android Studio are you using?
4.0.2
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
3
Describe the problem
Two problems:
Steps to reproduce?
Versions
What version of Android Studio are you using?
4.1.1
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-lists
In which task and step of the codelab can this issue be found?
4. Loop Through a List
Describe the problem
There is a note:
Note: Because doing a simple operation on a variable and storing it back in the variable is common, there is a shorthand for it using the += operator. There are equivalent operators for minus (-=) , multiplication (*=) and division (=). See more details here.
However, the division part is wrong. It should be /=
instead of \=
.
https://developer.android.com/codelabs/basic-android-kotlin-training-display-list-cards?
"Use cards"
I made the changes to add the Material Card View and the app would crash with a logcat error that "The style on this component requires your app theme to be Theme.MaterialComponents" Was on a Nexus 6 emulator. I was able to resolve it by changing the theme.
Steps to reproduce?
Just follow the instructions for adding the card view and run the app.
Versions
What version of Android Studio are you using?
4.0.1
Additional information
Perhaps I missed an instruction for changing the theme earlier in the codelab, but I went back through it and didn't see anything.
In which task and step of the codelab can this issue be found?
5. Put it all together
Describe the problem
For this:
Vegetables(listOf("cabbage", "sprouts", "onion"))
Names were all small cases, but other example was camelcase, like below (step 6)
val vegetables = Vegetables("Cabbage", "Sprouts", "Onion")
To make it consistent, I think it should be fixed as:
Vegetables(listOf("Cabbage", "Sprouts", "Onion"))
Steps to reproduce?
Versions
What version of Android Studio are you using?
Additional information
Include screenshots if they would be useful in clarifying the problem.
ItemAdapter.kt:
override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {
val item = dataset[position]
holder.textView.text = context.resources.getString(item.stringResourceId)
}
stringResourceId : "No members to implement have been found"
Versions
4.1.2
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-recyclerview-scrollable-list#3
In which task and step of the codelab can this issue be found?
Create a layout for items
Describe the problem
It says, "Alternatively, you could have used File > New > Layout Resource File, ..."
But actually the utility is seen by the path "File > New > XML > Layout XML File".
Steps to reproduce?
As stated above.
Versions
What version of Android Studio are you using?
4.2.1
Additional information
Nil.
In which task and step of the codelab can this issue be found?
"Use Lists in Kotlin" Step 8, the green boxed note about augmented assignment operators.
Describe the problem
(Typo) The division assignment operator is written in the box as \=. This should be /=.
If you follow the link to see more details, the operator is correct on that page.
Steps to reproduce?
This is just a typo, leaving these blank.
Versions
What version of Android Studio are you using?
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
Adding A RecyclerView To Your App/Create A Layout For Items
Describe the problem
Just for completion sake, A step for addingthe constraints to the TextView is missing.
Steps to reproduce?
Versions
What version of Android Studio are you using?
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-recyclerview-scrollable-list#3
In which task and step of the codelab can this issue be found?
Implement onBindViewHolder()
Describe the problem
In the sentence "The resulting string can be set as the text of the textView in the holder ItemViewHolder." it seems that "holder" should not be put into the code format, but it is.
Steps to reproduce?
As stated above.
Versions
Not applicable.
Additional information
Nil.
URL of codelab
URL of codelab
In which task and step of the codelab can this issue be found?
Task 4 (Loop through a list)
Describe the problem
The division assignment operator used backslash instead of a slash ("\=" instead of "/=")
In which task and step of the codelab can this issue be found?
Use lists in Kotlin/Put it all together/Create an order
Describe the problem
Typo in the sentence "the price of the so far"
Steps to reproduce?
Versions
What version of Android Studio are you using?
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
3. Polishing the UI
Describe the problem
Step 1 is listed as: Open list_item.xml (app > res > layout > item_list.xml) and add 16dp padding to the existing LinearLayout. While the directory is routing to the correct file name, it is initially mis-spelled as "list_item.xml".
In which task and step of the codelab can this issue be found?
Vegetables(listOf("cabbage", "sprouts", "onion")))
Describe the problem
Nothing spectacular but it should be:
Vegetables(listOf("cabbage", "sprouts", "onion"))
Steps to reproduce?
Versions
What version of Android Studio are you using?
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
listOf(1, 2, 3, 4, 5, 6) returns a red-only list of integers from 1 through 6.
Describe the problem
Type at returns a red-only list its read-only
Steps to reproduce?
Versions
What version of Android Studio are you using?
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
4. Loop Through a List
Describe the problem
!! Description Error in the below paragraph !!
Note: Because doing a simple operation on a variable and storing it back in the variable is common, there is a shorthand for it using the += operator. There are equivalent operators for minus (-=) , multiplication (*=) and division (\=)
. See more details here.
Falult: division (\=)
Correct: division (/=)
URL of codelab
In which task and step of the codelab can this issue be found?
In the TextView, set the textAppearance attribute to ?attr/textAppearanceHeadline6. textAppearance is an attribute that allows you to define text-specific styling. For other possible predefined text appearance values, you can see the TextAppearances section in this blogpost on Common Theme Attributes.
Describe the problem
Instead of having : Larger text I get almost invisible one even if I try with headline lower than 6 ( 5, 4 etc.)
Steps to reproduce?
Versions
What version of Android Studio are you using?
4.0.1
Additional information
Include screenshots if they would be useful in clarifying the problem.
My mistake.
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-lists
In which task and step of the codelab can this issue be found?
8. Summary
Describe the problem
The following code block format is broken:
In which task and step of the codelab can this issue be found?
"Initialize list of affirmations with images"
Describe the problem
missing the line which should be
"Affirmation(R.string.affirmation3, R.drawable.image3),"
from the code sample, the code has "2" and on the next line "4", missing "3".
Steps to reproduce?
Versions
4.1.1
URL of codelab
In which task and step of the codelab can this issue be found?
Describe the problem
Steps to reproduce?
Versions
What version of Android Studio are you using?
Additional information
Include screenshots if they would be useful in clarifying the problem.
3. Introduction to Mutable Lists. section 4. Create a list of moreItems. You won't have to change it, so make it a val and immutable.
In this codelab step it is about the kotlin mutable list and moreItems has to be a mutableListOf("ravioli", "lasagna", "fettuccine").
In the example the type of the moreItems is incorrect (it is immutable list),
val moreItems = listOf("ravioli", "lasagna", "fettuccine")
In which task and step of the codelab can this issue be found?
Task: Display a list of images using cards
Step: 3
Describe the problem
In the section "Update dark theme colors", the reader is asked to change the night/themes.xml status bar color by using the following line:
<item name="android:statusBarColor" tools:targetApi="l">@color/colorPrimaryVariant</item>
this line however causes an error as the color resource is not found. In the solution file on GitHub, this line is not changed and uses attr/colorPrimaryVariant
Steps to reproduce?
Versions
4.1.1 on Ubuntu
No information on library to import for List, codes in Kotlin playground show error
No information on library to import for List, codes in Kotlin playground show error
Write to codes as provided on Koylin Playground
fun main() {
val numbers: List = listof(1, 2, 3, 4, 5, 6)
println("List: $numbers")
println("Length = ${numbers.length}")
}
Error
Unresolved reference: listof
Unresolved reference: length
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-display-list-cards#2
In which task and step of the codelab can this issue be found?
3. Polishing the UI > Separate Styles from Themes > 6. Locate the line...
Describe the problem
In Codelabs, it is written : Locate the line that reads android:theme="@style/AppTheme" and change it to android:theme="@style/Theme.Affirmations".
With Android Studio 4.1.2, it should be written :
Locate the line that reads theme="AppTheme" and change it to theme="Theme.Affirmations".
URL of codelab
Hi! This is my first time using Git Hub.
In the course Display a Scrollable List, unit -> Display a list of images using cards, in the section Polishing the UI, the code that goes in the themes/night did not work and made my application crash in the dark mode display of the phone.
In which task and step of the codelab can this issue be found?
Display a list of images using cards, in the section Polishing the UI - > Add a resource file for dark theme -> Step 5 (Copy the following into the new themes.xml file (in the values-night directory).
Describe the problem
the next code line made that the application cant be initializated in the dark mode
@color/colorPrimaryVariant
i change it for and it worked
?attr/colorPrimaryVariant
Steps to reproduce?
Versions
What version of Android Studio are you using?
Additional information
Include screenshots if they would be useful in clarifying the problem.
Step 8, at code section
Wrap the while / loop declaration into an actual code block to display it
In which task and step of the codelab can this issue be found?
Unit 2: Layouts --> Display a scrollable list --> Use RecyclerView to display a scrollable list --> Before you begin --> What you'll learn
Describe the problem
The text: "How to use organize your code into packages" should read "How to organize your code into packages"
In which task and step of the codelab can this issue be found?
"Adding images to the list items" step 2
Describe the problem
The zipped folder of example images to be used within the project contained some sort of MacOS hidden folder. It was called "__MACOSX".
Steps to reproduce?
Obviously not a big deal, and it may not even be worth fixing. I just wanted to let it be known. People may appreciate the only files in the archive being image files.
I don't mean to be a complainer, and I'm grateful for these guides!
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
At the "5. Put it all together" section
Describe the problem
At the detailed explanation of the output of the code, the subclass of its parent class(Item)"Noodles" is called "Noodle"
Steps to reproduce?
Versions
What version of Android Studio are you using?
Additional information
Include screenshots if they would be useful in clarifying the problem.
Vegetables(listOf("cabbage", "sprouts", "onion")))
There is a residual parentheses at the end of the line of code above
It should be
Vegetables(listOf("cabbage", "sprouts", "onion"))
In which task and step of the codelab can this issue be found?
Remove elements from a list - Step 2
Describe the problem
We can not remove those elements in "entrees" which belong to the immutable list "moreItems".
.remove("element") only works for those elements of "entrees" list that were added using .add("element") method
This is not mentioned in this page.
Steps to reproduce?
Versions
What version of Android Studio are you using?
Android 11
Additional information
Include screenshots if they would be useful in clarifying the problem.
NA
Display a scrollable list - Display a list of images using cards
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/item_image"
android:layout_width="match_parent"
android:layout_height="194dp"
android:importantForAccessibility="no"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:textAppearance="?attr/textAppearanceHeadline6" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
Preceding code implements Material Component CardView. Actually CardView wraps up the LinearLayout here.
So you may find error if you're not having certain dependency in your gradle file.
All you need to do is, add the follwing code to dependencies section in build.gradle(Module: app) file. Then make it sync.
dependencies {
implementation 'com.google.android.material:material:1.0.0'
}
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-display-list-cards#2
In which task and step of the codelab can this issue be found?
Change the app icon
Describe the problem
In the sentence "If your browser shows the file instead of downloading it, select FIle > Save Page As... to save it to your computer." the "i" in "FIle" seems to have been falsely capitalized.
Steps to reproduce?
As stated above.
Versions
Not applicable.
Additional information
Nil.
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-recyclerview-scrollable-list
In which task and step of the codelab can this issue be found?
Step 4 - Create a ViewHolder
Describe the problem
Step 3 of Create a ViewHolder have an error how class name is formatted. It's RecyclerView
. ViewHolder
but the correct is RecyclerView.ViewHolder
Steps to reproduce?
Versions
What version of Android Studio are you using?
Android Studio 4.2.1
Additional information
Include screenshots if they would be useful in clarifying the problem.
good night, i'm sorry but this code dont generate one list.
pido disculpas por no ser mas especifico pero no se hablar ingles, el codigo no genera ninguna lista, he revisado el codigo multiples veces, he incluso copie todo el codigo y lo pegue android-studio y aun asi no genera ninguna lista, busque en la documentacion y encontre que otra forma de hacer un recyclerview es por otro paquete llamado listAdapter, aunque no entiendo mucho, de esto.
In which task and step of the codelab can this issue be found?
Change the App Icon
Describe the problem
The links to download the icons are broken. Here's what I get-->
foreground:
Here's what I get for the background icon-->
<aapt:attr name="android:fillColor">
</aapt:attr>
Steps to reproduce?
Versions
What version of Android Studio are you using?
Additional information
Include screenshots if they would be useful in clarifying the problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.