码迷,mamicode.com
首页 > 其他好文 > 详细

Activity的生命周期

时间:2015-11-03 17:25:47      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends Activity {
    ViewPager mViewPager;

    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mViewPager = (ViewPager) findViewById(R.id.vp);
        PagerAdapter mPagerAdapter = new myAdapter(this);
        mViewPager.setAdapter(mPagerAdapter);
        Log.e("MainActivity", "=========开始创建");
        Button button = (Button) findViewById(R.id.btn);
        button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, ActivityB.class);
                startActivity(intent);
            }
        });
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.e("MainActivity", "=============暂停");
    }

    protected void onDestroy() {
        Log.e("MainActivity", "=============完全退出");
        super.onDestroy();
    }

    @Override
    protected void onRestart() {
        Log.e("MainActivity", "=============重新开始");
        super.onRestart();
    }

    @Override
    protected void onResume() {
        Log.e("MainActivity", "=============正在运行");
        super.onResume();
    }

    @Override
    protected void onStart() {
        Log.e("MainActivity", "=============开启");
        super.onStart();
    }

    @Override
    protected void onStop() {
        Log.e("MainActivity", "=============结束");
        super.onStop();
    }

 

Activity的生命周期

标签:

原文地址:http://www.cnblogs.com/labixiaoxin/p/4933599.html

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