安卓——Activity生命周期、



 
  1. 在xml 设计页面添加标签
<? xml version= "1.0" encoding= "utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.administrator.app_style.MainActivity"
    android:orientation="vertical">

    <Button
    android:id="@+id/b1"
    android:text="click select!"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
    <Button
        android:id="@+id/b2"
        android:text="click Dx!"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

  2
 
/**
 * Created by Administrator on 2017/1/3.
 * 四大组件都需要注册-》跳转
 */

public class One extends AppCompatActivity {

//    顺序
//    正常
//
// On create -> 创建 Activity不可见
// On  start -> 推出去 Activity可见
// On resume->  用于暂停的回调Activity
// On pause ->  暂停 Activity
// On stop -> OnDestory 销毁Activity结束
//↓ ↑ ← →
//    Log →.d  debug    .e exception   .i info


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.timcopy);
        Log.e("s","onCreate ->");
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.e("s","onStart ->");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.e("s","onResume ->");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.e("s","onPause ->");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.e("s","onStop() ->");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e("s","onDestroy()");
    }
 
  
 
 
  1. 在xml 设计页面添加标签
<? xml version= "1.0" encoding= "utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.administrator.app_style.MainActivity"
    android:orientation="vertical">

    <Button
    android:id="@+id/b1"
    android:text="click select!"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
    <Button
        android:id="@+id/b2"
        android:text="click Dx!"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

  2
 
 
/**
 * Created by Administrator on 2017/1/3.
 * 四大组件都需要注册-》跳转
 */

public class One extends AppCompatActivity {

//    顺序
//    正常
//
// On create -> 创建 Activity不可见
// On  start -> 推出去 Activity可见
// On resume->  用于暂停的回调Activity
// On pause ->  暂停 Activity
// On stop -> OnDestory 销毁Activity结束
//↓ ↑ ← →
//    Log →.d  debug    .e exception   .i info


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.timcopy);
        Log.e("s","onCreate ->");
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.e("s","onStart ->");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.e("s","onResume ->");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.e("s","onPause ->");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.e("s","onStop() ->");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e("s","onDestroy()");
    }
 
 
  
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值