Android Change Activity

Source: Internet
Author: User

Like Change page

Change activity First we should create a activity,

We should extends class activity and override OnCreate (), then configure information in Androidmainfest.xml.

There importment attrbutes call name and label, name Attrbute tell Android system how to find activity and the label E AUQL the title of the activity.

 PackageCom.example.chatdemo;Importandroid.app.Activity;ImportAndroid.os.Bundle;Importandroid.support.v7.app.ActionBarActivity;/*** 1.a activity has to extends activity 1 * 2.override onclreate () method * 3. Configure information on ANDROIDMAINFE St.xml * <activity android:name= "com.example.chatdemo.MainActivity" android:label= "@strin                G/app_name "> </activity> this means default activity <intent-filter> <action android:name= "Android.intent.action.MAIN"/> <category android:name= "Android.intent.catego Ry. LAUNCHER "/> </intent-filter> **/ Public classChatextendsactionbaractivity{@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); //Setcontenview () when the execute this activity would dispaly follow layoutSetcontentview (r.layout.chat); }}

If you want go to the activity should set a onclick event

New Intent ();        Intent.setclass (this, chat. class );        StartActivity (intent);

Use class Intent Pack activity class finally use Method StartActivity () to start a activity.

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.