예제 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    // 如果activity是被用户按下back或者调用finish终止的,那onCreate里面的savedInstanceState变量为null
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ui_test_layout1);

    rootLayout = (LinearLayout) findViewById(R.id.ll_linearlayout_root);

    int count = rootLayout.getChildCount();
    for (int i = 0; i < count; i++) {

      Log.d(TAG, rootLayout.getChildAt(i).toString());
    }

    mTextView = (TextView) findViewById(R.id.textView1);

    if (savedInstanceState == null) {

      createActivitySharedPreference();
    } else {

      if (savedInstanceState.containsKey(TEXTVIEW_STATE_KEY)) {

        mTextView.setText(savedInstanceState.getString(TEXTVIEW_STATE_KEY));
      }
    }
  }
예제 #2
0
  @Override
  public void onTrimMemory(int level) {

    // 接收UI被隐藏的消息,此时需要释放你的UI所占用的资源
    if (level == Activity.TRIM_MEMORY_UI_HIDDEN) {}

    super.onTrimMemory(level);
  }
예제 #3
0
  /**
   * 这个函数是在Activity被RunTimer终止时才会调用的(比如屏幕旋转的时候). 也就是说如果该activity是被用户按下back键或者调用finish函数终止的 ,那
   * onSaveInstanceSate函数是不会被调用的
   */
  @Override
  protected void onSaveInstanceState(Bundle outState) {

    Log.d(TAG, "onSaveInstanceState");

    // 在Shared Preferences中存储新的基本类型
    outState.putString(TEXTVIEW_STATE_KEY, "bbbbbbbbbbbbbbbbbbbbbbbbbbbb");

    super.onSaveInstanceState(outState);
  }
예제 #4
0
 @Override
 protected void onResume() {
   super.onResume();
   Log.d(TAG, "onResume");
 }
예제 #5
0
 @Override
 protected void onStart() {
   super.onStart();
 }
예제 #6
0
 @Override
 protected void onDestroy() {
   Log.d(TAG, "onDestroy");
   super.onDestroy();
 }
예제 #7
0
 @Override
 protected void onStop() {
   Log.d(TAG, "onStop");
   super.onStop();
 }
예제 #8
0
 @Override
 protected void onPause() {
   super.onPause();
   Log.d(TAG, "onPause");
 }