Code example for Field

Methods: get, setAccessible

0
  } 
 
  public boolean isAttachedToWindow() { 
    try { 
      Field mAttachInfo = View.class.getDeclaredField("mAttachInfo");
      mAttachInfo.setAccessible(true);
      return mAttachInfo.get(realView) != null;
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    } catch (NoSuchFieldException e) {
      throw new RuntimeException(e);
    } 
  } 
 
  public void callOnAttachedToWindow() { 
    invokeReflectively("onAttachedToWindow"); 
  } 
 
  public void callOnDetachedFromWindow() { 
    invokeReflectively("onDetachedFromWindow"); 
  }