码迷,mamicode.com
首页 > 移动开发 > 详细

Android Change Activity

时间:2014-08-12 18:40:24      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   color   os   io   for   ar   

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 two importment attrbutes call name and label ,name attrbute tell android system how to find activity and the label eauql the title of the activity .

package com.example.chatdemo;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;

/**
 * 1.a activity have to extends Activity 1
 * 2.override onClreate() method
 * 3. configure information on AndroidMainfest.xml 
 *        <activity
            android:name="com.example.chatdemo.MainActivity"
            android:label="@string/app_name" >
        </activity>
        this means default activity 
        <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
 * */
public class chat extends ActionBarActivity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        
        super.onCreate(savedInstanceState);
        //setContenView() when execute this activity will dispaly follow layout  
        setContentView(R.layout.chat);
    }

}

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

Intent intent = new Intent();
        intent.setClass(this, chat.class);
        startActivity(intent);

 

use class Intent pack activity class finally use method startActivity() to start a activity .

 

Android Change Activity,布布扣,bubuko.com

Android Change Activity

标签:android   style   blog   color   os   io   for   ar   

原文地址:http://www.cnblogs.com/oaks/p/3907808.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!