Simple Steps To Create And Link An New Activity
Create An New Activity Using Android Studio
1.Start Android Studio..
2.Now,Lets Understand How To create an New Activity....For that we will Need to create..
a.New Layout File...ie. XML file
b.New Java Class...ie. Java File..
3.Lets Start....
Firstly, Make New layout file ie. Your Xml file
Go to res...Double click on Layout->New->XML->Layout Xml File.... as shown...
4.Name the Layout File with appropriate name and say finish....(Provide in small case letters...)
5.Your New activity XML file has been created..which should be something like this....
6.Now....Lets Create the Java File....
Double click on MainActivity->New->Java Class...
Select Java Class..
7.Provide Appropriate name to the Java File...
8.Your Java file must be something like this...
9.Now,Lets Design the Main Activity Layout...Open Your Main Activity layout..Drag a simple Button and name it as per your requirement..Also,Provide a name for "OnClick" property in properties...
12.Now Lets Update the Manifest File....Always Remember while creating a new activity you need to update your manifest file....
just add the following into your manifest file....
13.Lastly..Lets work with mainActivity.java file and then you are done......Add The Following method into your mainActivity.java file..(Press alt+enter to include those packages if error occurs)
14.Now Lets Run the App and Test on Emulator...
Its Working...!!
If You are New or Don't Know How To Run App On Emulator Go to My Following Link...
Run App On Emulator..
1.Start Android Studio..
2.Now,Lets Understand How To create an New Activity....For that we will Need to create..
a.New Layout File...ie. XML file
b.New Java Class...ie. Java File..
3.Lets Start....
Firstly, Make New layout file ie. Your Xml file
Go to res...Double click on Layout->New->XML->Layout Xml File.... as shown...
4.Name the Layout File with appropriate name and say finish....(Provide in small case letters...)
5.Your New activity XML file has been created..which should be something like this....
6.Now....Lets Create the Java File....
Double click on MainActivity->New->Java Class...
Select Java Class..
7.Provide Appropriate name to the Java File...
8.Your Java file must be something like this...
10.Now design the layout of New Activity...Open the New Activity layout file..and design something which should be displayed after hitting the button on main activity which we created just before...
11.Now Lets Work with coding part...Open Your New Activity Java file.......Here You Need to...
a.extend the class to Activity..
b.Add Bundle to the file...(You can add or copy paste from your mainactivity.java file)
Your new activity java file should be like this....(Press alt+enter to include those packages if error occurs)...
12.Now Lets Update the Manifest File....Always Remember while creating a new activity you need to update your manifest file....
just add the following into your manifest file....
<activity android:name=".newactivity"></activity>
13.Lastly..Lets work with mainActivity.java file and then you are done......Add The Following method into your mainActivity.java file..(Press alt+enter to include those packages if error occurs)
14.Now Lets Run the App and Test on Emulator...
Its Working...!!
If You are New or Don't Know How To Run App On Emulator Go to My Following Link...
Run App On Emulator..
Thank You..!!
Comments
Post a Comment