I am working with Android Studio and Kotlin.
I am trying to use different images in my project (in drawable):
But when I am trying to use one in the DataSource file, it happens an error:
package com.example.affirmations.data
import com.example.affirmations.R
import com.example.affirmations.model.Affirmation
class DataSource {
fun loadAffirmations():List<Affirmation>{
return listOf<Affirmation>(
Affirmation(R.string.affirmation1, R.drawable.image1),
// Affirmation(string.affirmation2, R.drawable.image2),
// Affirmation(string.affirmation3, R.drawable.image3),
// Affirmation(string.affirmation4),
// Affirmation(string.affirmation5),
// Affirmation(string.affirmation6),
// Affirmation(string.affirmation7),
// Affirmation(string.affirmation8),
// Affirmation(string.affirmation9),
// Affirmation(string.affirmation10)
)
}
}
Thank you
CodePudding user response:
Wherever you define Affirmation
(you can hold Ctrl or whatever and click it to go there) it's expecting an Integer resource for the second parameter - it's probably annotated with @IntegerRes
instead of @DrawableRes