Code example for Field

Methods: setInt

0
  } 
 
  private void setIntegerField(Object target, String fieldName, int value) {
    try { 
      Field f = target.getClass().getField(fieldName);
      f.setInt(target, value);
    } catch (Exception e) {
      mErrors.add("set field)" + fieldName + " failed. " + e.toString());
    } 
  } 
 
  private int getColor(String value) {
    if (value.startsWith("#")) {
      try { 
        return (int) Long.parseLong(value.substring(1), 16);
      } catch (Exception e) {
      } 
    } 
    mErrors.add("Unknown color " + value);
    return 0; 
  }