android 捕捉焦点获取和失去

  • 内容
  • 评论
  • 相关
package com.example.settitle;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		setTitle("窗口标题");
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		Log.d("onResume","focus has miss");
		super.onPause();
	}

	@Override
	public void onWindowFocusChanged(boolean hasFocus) {
		// TODO Auto-generated method stub
		Log.d("onWindwosFocusChanged",hasFocus ? "focus catch" : "focus miss");
		super.onWindowFocusChanged(hasFocus);
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		Log.d("onResume","focus has catch");
		super.onResume();
	}
	
	

}

其中,onWindowFocusChanged方法与生命周期调用的方法没有直接关系,此方法会在onResume或者onPause方法后调用。

评论

0条评论

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注