есть класс Drink
package com.example.starbuuz
class Drink(name:String, description:String, imageResourceId: Int) {
private var name:String = name
private var description:String = description
private var imageResourceId: Int = imageResourceId
public var drinks:Array<Drink> = arrayOf(
Drink("Latte", "A coupleof espresso shots with steamed milk", R.drawable.latte),
Drink("Cappuccino", "Espresso, hot milk, and a steamed milk foam", R.drawable.cappuccino),
Drink("Filter","Heighest quality beans roasted and brewed fresh",R.drawable.filter)
)
public val getName:String
get() = name
public val getDescription:String
get() = description
public val getImageResourceId:Int
get() = imageResourceId
}
который хочу импортировать в класс DrinkCategoryActivity
package com.example.starbuuz
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.ArrayAdapter
import com.example.starbuuz.Drink
class DrinkCategoryActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_drink_category)
val listArrayAdapter: ArrayAdapter<Drink> = ArrayAdapter<Drink>(this,
android.R.layout.simple_list_item_1,
Drink.drinks
)
}
}
при обращении к переменной класса Drink.drinks подчеркивается красным слово drinks
это код из книги по Head_First._Programmirovanie_dlya_Android страница 309
результат