Activity details for Android Development (sumzom) and activitysumzom

Source: Internet
Author: User

Activity details for Android Development (sumzom) and activitysumzom

In an app, an activity usually refers to a single screen, which is equivalent to a webpage in a website. It is visible to users and can display some controls on it, you can also listen to the user's time to respond.

How can activities communicate with each other? They communicate and switch through intent. Intent has two important parts: Action transmission and data transmission );

Is Shenma an Activity?

Activity is a four-component interface that allows users to operate and interact with users. For example, you can take a photo and log on to the registration page. An application is usually composed of multiple activity loose coupling (low coupling). When the user opens the first interface that the app sees, we call it MianActivity. One activity can start another activity. When a new activity is started, the previous activity will stop, but the system will save it to the back stack and get the user focus. Back stack follows the principle of "back-in-first-out". When you press the Back key on your mobile phone, the current activity is removed from backstack and the previous activity is restored.

Activity callback function: creates, starts, recovers, pauses, stops, and destroys the Activity;

Bind view: SetContentView (view)

Activities communicate with each other through intent.

Intent intent = new Intent (MainActivity. this, orther. class );

StartActivity (intent );

Ø MVC mode:

M (Model): Model is the main part of the application. All business logic should be written here. In Android, the Model layer and JavaEE do not change much, for example: database Operations, network operations, and so on are all placed on this layer (not to mention that they are all placed in the same package and can be opened separately, but they are collectively referred to as the Model layer ).
V (View): it is the part in the application that generates the user interface. It is also the only layer that users can see throughout the MVC Architecture. It receives user input and displays processing results; android applications generally use the description of the XML file Reed interface, which can be easily introduced. Of course, JavaScript + Html can also be used as the View.
The control layer of C (Controller control layer) android is very important to many activities. Therefore, it is recommended that you do not write too much code in the activity, try to process the business logic layer of the activity delivery Model.

Ø how to operate the style and topic of an activity?

By default, an activity occupies the entire screen. You can also customize the Activity and display it in a window to remind Yonghui to perform some operations. In this case, it is a good method to display the activity in the form of a dialog box to attract the user's attention.

Modify the <Activity/> label in the AndroidManifest. xml file and add the android: theme attribute.

Example: <activity

Android: theme = "@ android: style/Theme. Dialog"

Android: name = "com. example. helloandroid. MainActivity"

Android: label = "@ string/app_name"> </activity>

Ø hide the Activity title (ActionBar)

Method 1:

Declare before binding a view in the code

@ Override

Protected void onCreate (Bundle savedInstanceState ){

Super. onCreate (savedInstanceState );

RequestWindowFeature (Window. FEATURE_NO_TITLE); // hide the title bar before binding the view. //

SetContentView (R. layout. activity_main );

// Bind the view layer

InitWithView ();

Intent intent = new Intent ();

StartActivity (intent );

}

Method 2:

In the AndroidManifest file:

<Activity android: name = ". Activity"
Android: theme = "@ android: style/Theme. NoTitleBar"
> </Activity>

I believe you have a preliminary understanding of the activity !!!

Your reading is my greatest motivation. My post will be updated faster and faster --!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.