Link Two Activities - Android Studio latest version

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys so in this video I'm going to show you how you can link one activity to another in Android studio so you can do this process through any layout like constraint linear scroll view anything I have done videos on these layouts so you can watch them the link is in the description and yeah let's jump [Music] yeah so once you have created a new project and selected the empty activity then you will or this page will open which will have the constraint layout now we have to go from one page to another right so first we'll create a button here button which the width will match parent and it will wrap content and we'll just give some text for the button Android text activity one all tend to ignore coded text and now we'll give an ID to the button Android ID at the red plus ID / and we'll write some ID bTW and then now we'll just align this button will take it here somewhere and then we will just kind of resize it get your fix it on the screen then we have done the first activity now we will create the second activity we will right click on layout new activity and empty activity we will name it activity two to finish now the second activity is created right now we will go to the XML file of activity two here we will create something like textview so I just write text to you the width will match parent height will wrap content will and enter some text Android text welcome to activity to alt enter hot coded text Android text size will be 30 SP Android text color will be black done now we'll just align it somewhere and fix it on the screen yeah we'll give the text alignment to Center it text alignment Center then now the second activity is created now the main part comes when we are going to link the first main activity to the activity to now go to the Java file of main activity here we'll import three classes import Android dot widget dot button semicolon import Android dot content dot intent semicolon import Android dot view not view semicolon then now inside the main activity will create the object of the button public button button semicolon and inside this we'll click enter enter and then name of the object button equals to brackets button find view by ID r dot ID and we'll specify the ID that we had given in the main file see here what I did we give bTW and right so we'll go here we'll specify the ID B T and and semicolon next you will write button dot set on click listener new view dot on click listener and in that will just create intent intent equals to new intent and will specify the name of the first activity and then the second activity now the first activity here is main activity right so we'll write main activity dot this comma activity to activity to dot class and we'll give the semicolon and then we'll start activity start the activity and in this we'll call the object in intent so done now just run this on the mobile phone I'll show you how it how the activities are linked to on the mobile phone my ID is a little slow so I'll just debug it so this is the main activity the first activity that we had created now once I click on the button it will go to the second activity so the code we had implemented is successfully running we can go back and forth we can also go back so this is how you can link to activities to each other so please leave a like if you find this video useful and I am coming up with a series of android tutorials so you can watch it on my channel by subscribing to my channel and share the video with your friends if you find it useful and thank you
Info
Channel: With Sam
Views: 39,468
Rating: 4.8698225 out of 5
Keywords: Random, Technology, How to, Android Studi, Android Studio Latest, Programming, Linear Layout Android, Android Tutorial, Link Activities in Android Studio, Android development
Id: dm-jan0YORg
Channel Id: undefined
Length: 6min 6sec (366 seconds)
Published: Sat Apr 06 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.