Now using all the components of UI which we studied, we will create activities. And in this we will pass some data from one activity to another activity.
We will see that how we can pass data from first activity to another activity, for that we will create an activity named 'DataPassing'.
Now inside that we will design two activities, to perform this thing we will design two layouts respective to both of the activities. First we'll open 'activity_first.xml'.
In which we have used one Linear layout, in which we have set its properties like height, width, padding etc... and in context we are showing that for which activitiy we are designing this layout.
After that we will do you identification for that,
We have taken different type of text views here, whose basic properties we have set, like for first Textview we have set our text as ""First Activity"" and set all the colors we want.
As it is a linear layout so we have specified it before that orientation will be vertical. And after that we have taken three different kinds of EditText, as we want our user to enter their information.
And at last we have taken a button. On click event of this button we will pass our data.
Now in our second activity 'activity_second.xml' file, we have taken Relative layout, and set all the properties of it. And in context we have shown that it is for second activity.
We have taken a textview in which we have to show the relative position of one component to another component.
After that we have taken next textview in which we have shown text that appears when data is passed, it is ""Data passed successfully"".
Now we will see the code for first activity in 'FirstActivity.java' file, here we have done view identification for our two textViews, three editText and one button.
After that we have taken one OnClickListener,
public void onClick(View v)
Intent intent1=new Intent(firstActivity.this,SecondActivity.class);
Now inner 'SecondActivity.xml', the intent which we are getting in second activity we are passing that here,
To catch the particular data we will be using 'Bundle',
Now we will use two strings for first name and last name,
Have a friend to whom you would want to share this course?