BEST WAY OF PASSING DATA FROM ONE ACTIVITY TO ANOTHER ACTIVIY IN ANDROID STUDIO KOTLIN

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome to my channel today in this video tutorial we are going to learn about uh transferring data from one activity to another activity and android cortland so let's start so i've created this project in which i have this activity man.xml and this main activity dot kt file this is our designer file this one and this is our code file so now i'll quickly drag and edit text and i will select this plane edit text and i will drag it here now i'll drag in another i'll come to this text section and another edited text and now i'll place them and the middle as well as this one and now i'll pin in this first one this one from the top and i will append this to this side as well as this other side i'll select it again and now i'll select this end to this side and now i'll quickly add constraint on this as well so i'll append this to this side as well as to this other side and now open it from the top as well now our we have constrained our uh edit text so now i'll come to this button section and now i'll drag in a button here and um now i'll uh go to this code and here i'll come down to button this one and now i'll give this an id of trans underscore data and now i'll make this match parent and now i'll give it a and a text transfer data and now i'll go to design again and now i will quickly pin this from the top and i'll give it a 24 dp and from this side as well as this side and i'll give it a 24 db from this side and 24 db from this side and now i'll uh quickly go to this code file or i'll go to this a code again and i will remove this name text from the setted text and remove this as well as from this other one and now we are good to go so if i come to design now we do not have any text inside this now i'll go to this main activity.kt file and here i'll connect the edit text so in the wall et 1 or et equal to find uh view by id and this is edit text and i'll name this r dot id dot and edit text name person name so this is our id and now i'll add in another wall et2 equals find you by idr and this is edit text and i will call this r dot id dot uh person name two and now i'll also connect the button so wall btn equals find view by id and this is button and here i will use r dot id dot uh uh trans data this is the idb given to our button and now i'll um add a click even to this button so button dot set on click listener and here i will use view on on click listener and it will automatically create or click listener now we have to add another activity into our project so that we can transfer data to direct activity so i'll click on this right click on this package name and now i'll come to this activity and add in empty activity and here i will name this show data activity and now i'll click finish so now our activity is created so i will quickly go to its uh design file and i i will quickly drag a text view here and i will drag it to the top and give it some margins 32 db from the top or i will give it a 100 dp from the top and now i'll pin it to this side as well as this side and [Music] now i'll drag in another one for the second edit text value so i'll pin it from the top i'll pin it to this side as well as this side so it will stay in the middle of this designer now i'll go to code and here i will change the text size so i'll change the text size to text size to 18 sp and similarly i will change the text size of the second textview as well so i'll change text size and it will take 18 sp and now if i go to design and check the size now it is a bit bigger but it is not bigger enough so i'll make this 22 and this is well 22. now if i go to design now it is looking good now i'll uh go to its code file and now i'll connect in this textview so t1 equal to find view by id and text view and i will use r dot id dot text view and now i'll also add the txt to equals find view by idea or text view view and i'll use r dot id dot text view too and now uh i'll go to first man activity and here on this button click i'll create the intent so i'll use wall intent equals intent and then it takes the context so i'll give this comma and now it takes the second activity so i'll take show data activity and then it takes for columns and then it takes class.java and then we start activity and i pass in the intent so this will uh start this new in activity this show data and open it but we have to pass data with it so i'll use here intent dot port extra and here i can pass in a value so i'll pass in name and i'll use a e t dot text dot to string and similarly i'll put the data from the second edit text so i'll use here city and i'll put comma here and i'll use et 2 dot um text dot to string and now as you can see we have uh text uh string values here so now i will go to this uh show data activity and here i will get this so i'll use here wall intent equals intent and now i can get values from this intent so i'll use a string um name equals and so i have to use a wall here instead of this string so wall and 10 dot gate as we have passed and the string values so i'll use string here we if we have passed intent end values then we would have used git and extra so now name and then wall city equals intent dot get string extra and this is also city and then is i'll use uh txt one door text equals so this 61 is showing error because we haven't closed this so i'll close this one.txt equals name and here i'll use txt to text equals city and now we will run this and we will check the same so now the application is running on the device so if i enter a name here so my name is on my city is peshawar and now if i click on this transfer data now you can see in my name is khan and my city is p shower or transport to this second activity if i go back and now if i change this to some other values and if i use mik is my name and i will pass in some other values here so i live in india and now if i transfer this now you can see my name in my case my name and uh i live in india is uh transferred from that activity into this activity so that's all for today i hope you like the video if you like the video please like subscribe and comment thank you
Info
Channel: Programming Guru
Views: 120
Rating: undefined out of 5
Keywords: Programming Guru, Guru Programming, programming, gurru, programminggurru, Best way of passing data from one activity to another activity in android studio kotlin, passing data between activities in android kotlin, transfer data from one activity to another in android studio, tranfer data between pages in android studio kotlin, how to pass data from one page to another in kotlin android, pass data from one screen to another screen, best way to pass data in android activites kotlin
Id: JZZtBJQRKXI
Channel Id: undefined
Length: 13min 5sec (785 seconds)
Published: Sun Dec 05 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.