Skip to content

UvrajSB/Roll_it

Repository files navigation

Tutorial on Introduction to Native Android Development

Notes

  • We work on two different types of files - kotlin files and XML files
  • We create and arrange all the UI elements (views) in XML file.
  • Views are arranged using layouts, in this app we have used constraint layout.
  • Once the views are created and arranged properly in XML file, we move to Kotlin (.kt) file where we write the all the programs which determine the interaction with those views.
  • As the views are created in XML file but the functionality of those views is generated by the programs in kotlin file. So, we need reference of views in kotlin file. We use findViewById for that.
  • findViewById creates the reference of the views in kotlin file by the help of id defined in XML file for respective views.
  • We then created a function roll() which simply returns a random int between 1 to 6.
  • image
  • After that we used when statement to get the corresponding image resource to use in the imageView everytime user press Roll button and the image needs to be updated.
  • image
  • Finally we set the resource using setImageResource method.
  • We also displayed a Toast - which is nothing but a message that is displayed on the screen stating what number you have got.

Screenshots of the app

How to clone the app

  • Please star the repo first. (So that I can know that you are doing the task)
  • image
  • In android studio go to File > New > Project from version control
  • image
  • On the repo click on code and then copy the HTTPS from there
  • image
  • Copy this HTTPS in android studio
  • image
  • Just click on clone and now you are good to go.

How to run the app

Please go through this if you dont have an AVD already (To check it just press Run button and see if an AVD is opening up or not)

https://youtu.be/6CIPovJxty8

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages