public static int generateViewId(){
  for (; ; ) {
    final int result=sNextGeneratedId.get();
    int newValue=result + 1;
    if (newValue > 0x00FFFFFF)     newValue=1;
    if (sNextGeneratedId.compareAndSet(result,newValue)) {
      return result;
    }
  }
}

public static int generateViewId ( ) { for ( ; ; ) { final int result = sNextGeneratedId . get ( ) ; int newValue = result + 1 ; if ( newValue > 0x00FFFFFF ) newValue = 1 ; if ( sNextGeneratedId . compareAndSet ( result , newValue ) ) { return result ; } } }
generate a value suitable for use in setid ( int ) this value will not collide with id values generated at build time by aapt for r . id .
