Posts

Showing posts from January, 2018

Remove findViewById in Kotlin-Android

Remove findViewById in Kotlin From the newbie to the oldest developers in Android development knows the use of findViewById(). It is by far the commonest method used. When using this we associate a link between the XML  view to the object view in Java file. Let me remind the terminology for this, well this exactly what we refer to as View Binding.  In Kotlin, view binding is far more feasible and easy, as we got here a new plugin to add, and whoosh no findViewById() to remember every time we create a new view object. All you need to do is add a line in your 'build.gradle' file and its done.  apply plugin: 'kotlin-android-extensions' Now, how do we use this? import kotlinx.android.synthetic.main.activity_main.* class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) btnNextScreen.setOnClickListener{ v

Kotlin Beginners Guide

Kotlin The New Language for Android Development Kotlin is a new official language for Android by Google. After, literally drowning in Android language for so many years, we developers have to learn a new language in process to be competitive in market. Anyways, it is what it is.  Why a new Language ? I don't know how many of you have thought but I have been thinking a lot why a new language on whole? Always we have used Java for android development, but that doesn't make it our best choice. Since Java 8, developers are trying to fill the gap from previous versions to new versions, but android on whole doesn't support Java 8 fully. Kotlin relatively new language based on JVM (Java Virtual Machine) enables us to follow a new horizon of development. Kotlin is compatible from latest JDK to JDK6 , meaning Kotlin application can run from older devices to new devices. Having similar byte code structure enables Kotlin applications to run as fast as Java. Kotlin enables to