fahad005

ImageView (kotlin)

Oct 25th, 2021
966
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.firstapplication
  2.  
  3. import androidx.appcompat.app.AppCompatActivity
  4. import android.os.Bundle
  5. import android.widget.ImageView
  6. import androidx.appcompat.content.res.AppCompatResources
  7.  
  8. class MainActivity : AppCompatActivity() {
  9.  
  10.     override fun onCreate(savedInstanceState: Bundle?) {
  11.         super.onCreate(savedInstanceState)
  12.         setContentView(R.layout.activity_main)
  13.  
  14.         // this part
  15.         val img = findViewById<ImageView>(R.id.imageView)
  16.         img.setImageDrawable(AppCompatResources.getDrawable(this, R.drawable.images))
  17.     }
  18. }
RAW Paste Data