How To Open A New Activity Android Studio With Button Click (Java and Kotlin Example)
You would learn how to open a new Activity from a Button click. We would use a click listener on the button and then create a new Intent, then finally pass it to the startActivity method.
In this lesson, I would open a new activity using Kotlin as an example and also using Java for the example.
The first step is to create a click listener for the button in the main activity using the findviewbyID.
You then create an Intent in MainActivity which would collect the context and the Java class of the Android Activity to be opened.
Then we call startActivity method and pass in the intent.
I would demonstrate how to open a new activity using Kotlin and Java.
#LemubitAcademy
Views :33749
android studio