Created
August 28, 2018 19:43
-
-
Save codingpizza/f6d9c5f4bb1f6a2196a7673dc2b905c3 to your computer and use it in GitHub Desktop.
MainActivity Kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.codingpizza.cda9 | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import android.view.View | |
import android.widget.Button | |
import android.widget.ImageView | |
import com.bumptech.glide.Glide | |
class MainActivity : AppCompatActivity() { | |
private var imageView: ImageView? = null | |
private var button: Button? = null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
imageView = findViewById(R.id.imageView) | |
button = findViewById(R.id.button) | |
button?.setOnClickListener { loadImage() } | |
} | |
private fun loadImage() { | |
imageView?.let { | |
Glide.with(this) | |
.load("https://s22.postimg.cc/572fvlmg1/vlad-baranov-767980-unsplash.jpg") | |
.into(it) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment