SahobaDataClass(shablon uchun)
class SahobaData(private val logoID: Int, private val name: String, private val imageID: Int, private val description: String) {
fun getLogoID(): Int {
return logoID
}
fun getName(): String {
return name
}
fun getImageID(): Int {
return imageID
}
fun getDescription(): String {
return description
}
}
InfoActivity qismi:
class InfoActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_info)
val controller: DataController = DataController.getInstance()
val bundle: Bundle? = intent.extras
val pos: Int = bundle?.getInt("id") ?: 0
val sahoba: SahobaData = controller.getSahobaPosition(pos)
val image: ImageView = findViewById(R.id.imageSahoba)
val text: TextView = findViewById(R.id.textDescription)
image.setImageResource(sahoba.getImageID())
text.text = sahoba.getDescription()
val back: ImageView = findViewById(R.id.back)
back.setOnClickListener {
finish()
}
}}
Dastur ko’rinishi
Dostları ilə paylaş: |