What Is Activity In Android | Activity In Android Studio | Android Activity Explained In Detail


What is Activity?

An activity is one screen of the Android app. In that way, an Android activity is very similar to window in windows operating system.

To be more specific, the building block of the user interface is the activity. An Android app may contain one or more activities, meaning one or more screens. For e.g. Login, Sign-up & Home screen.

And activity class is a predefined class in Android and every application which has UI must inherit it to create window.

How Activity works?

Activity in Android is a platform or a specifically combination of XML file and Java file It is basically a container which contains design as well as coding stuff.

XML file provides you with the design of your screen.

Java file deals with all the coding stuff like handles what's happening in the design file, getting data which user has inserted into it.

How to create an Activity?

Way 1:

  • Create XML file (add “activity_” before file name. E.g. activity_main.xml).
    • Insert Relative Layout & TextView in xml file.

  • Create java file (add “Activity” after the file name, e.g. MainActivity.java).
    • Override  onCreate(Bundle savedInstanceState) Method.
    • Call setContentView(R.layout.activity_main)

  • Declare activity in the manifest.
    • If you want to make activity as first screen. Write these tags inside activity tag.
      
      
      
      
      


Way 2 (Bonus):

Create all activity component automatically using android studio wizard (watch the video for that).

That's all Folks, if you still have any confusion, clear them by commenting below.
And Be Updated with our YouTube Channel.

Comments

  1. I think this is the minimum value to earn more than just commitdata science certification malaysia

    ReplyDelete
  2. Happy to visit your blog, I am by all accounts forward to more solid articles and I figure we as a whole wish to thank such huge numbers of good articles, blog to impart to us.
    data science course in delhi








    ReplyDelete
  3. I think I have never watched such online diaries ever that has absolute things with all nuances which I need. So thoughtfully update this ever for us.
    https://360digitmg.com/course/project-management-professional-pmp

    ReplyDelete
  4. Hey amigos, it is incredible composed piece completely characterized, proceed with the great work continually.
    https://360digitmg.com/course/data-analytics-using-python-r

    ReplyDelete

Post a comment