المشاركات

How To Create New Activity And Open it with Button Click in Android Studio Using Kotlin :

 For Video Tutorial  Click here

Step 1 :


Step 2 :
  • Create new Project With Empty Activity ,
  • Go to java folder in project section (top left corner) in Android studio
  • Find "MainActivity".
  • Right Click on "MainActivity" 
  • Click "New" , 
  • Then click"Activity" 
  • Select "empty activity" 
  • Click "Finish"


Step 3 :
  • Create Button in Activity_Main.xml
  • Open  "MainActivity" kotlin file.
  • Add following Code in onCreate Method

 button.setOnClickListener {  
 val intent = Intent(this, Main2Activity::class.java)
    startActivity(intent)
}
  • If you got any error with code press "alt+enter"
  • Done. Run the App

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.