After a lot of 'ArrayIndexOutOfBound' messages, this for-loop works for me, but only because I compensated with (i-1).
Doesn't --i(t) means: _before entering the loop, decrement by one?
for (int i = offset; i > 0; --i) {
if (Character.isLetter(lnCmplt.charAt(i - 1))) {
selStart -= 1;
Log.i("1.for (i-1)= ", (i-1)+" char=["+lnCmplt.charAt(i-1)+"] selStart= "+selStart);
}
}
Log.i console output (it is real, only trimmed):
lnStart= 492 lnEnd= 506 offset= 7 // from Log line before
I/1.for (i-1)= 6 char=[e] selStart= 6 //<-- this value has to be 5 (i=7 ; --i (=6) ; i-1 (=5)
I/1.for (i-1)= 5 char=[k] selStart= 5 ...
[Edit] Solution: On first loop the x-crement isn't executed.