462
1.初始化OnGlobalFocusChangeListener
private ViewTreeObserver.OnGlobalFocusChangeListener focusChangeListener = new ViewTreeObserver.OnGlobalFocusChangeListener() {
@Override
public void onGlobalFocusChanged(View oldFocus, View newFocus) {
if ((oldFocus != null)) {
Log.d("info", "oldFocus ==" + oldFocus+" id:"+oldFocus.getId());
}
if (newFocus != null) {
Log.d("info", "newFocus ==" + newFocus+" id:"+newFocus.getId());
//如果得到的newFocusId为基础控件的id,则调用它的getParent()可以获取父控件的id,可依次类推
Log.d("info", "newFocus ==" + newFocus+" id:"+newFocus.getId()+" parentId:"+newFocus.getParent().getParent());
}
if (mAccesslayout.hasFocus()){
//L