Android Learning "Activity interface Jump"

Source: Internet
Author: User

First, interface jump
1. Define a new activity step:
1) Define a layout view (activity2_main.xml file),
2) Define a subclass that inherits activity (in the Mainactivity2.java file)
3) in the MainActivity2 class, override the life cycle method OnCreate () call Setcontextview () to bind the view (XML, hard-coded) to the activity sub-class

setContentView(R.layout.activity2_main);

4) Register the activity subclass with the Androidmanifest.xml manifest file (two methods):
Show Call

<activity            android:name="com.example.dave.myapplication.MainActivity2"            android:label="@string/app_name">        </activity>

implicit invocation

    <activityandroid:name="Com.example.dave.myapplication.MainActivity2"  Android:label="@string/app_name">                                    <intent-filter>                <action android:name="Star_login" />                <category android:name="Android.intent.category.DEFAULT" />            </intent-filter>    </activity>

5) Define a intent object within Mainactivity and invoke the Startacitivity () method of the current activity to start the new acitivity.
Display definition:

            //MainActivity2为跳转的组件        new Intent(MainActivity.this, MainActivity2.class);                startActivity(intent);

Implicit definition:

        new Intent("star_login");                startActivity(intent);

Android Learning "Activity interface Jump"

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.