以下代码适用于 Android 4,但在 Android 2 中会导致 IllegalArgumentException。
有什么线索吗?
Locale currentLocale = new Locale("en_UK");
final BreakIterator boundary = BreakIterator.getSentenceInstance(currentLocale);
boundary.setText("a");
int thisThrowsExceptionInVersion2 = boundary.preceding(1);
例外:
08-08 22:29:14.414: E/AndroidRuntime(329): Caused by: java.lang.IllegalArgumentException
08-08 22:29:14.414: E/AndroidRuntime(329): at java.text.RuleBasedBreakIterator.validateOffset(RuleBasedBreakIterator.java:74)
08-08 22:29:14.414: E/AndroidRuntime(329): at java.text.RuleBasedBreakIterator.preceding(RuleBasedBreakIterator.java:158)
08-08 22:29:14.414: E/AndroidRuntime(329): at kalle.palle.namespace.KallePalleActivity.onCreate(KallePalleActivity.java:26)