【发布时间】:2015-04-26 13:51:47
【问题描述】:
我在尝试转换为 CharSequence[] 时不断收到此错误。
字符串类型的 toArray(CharSequence[]) 方法未定义
这是我的代码
CharSequence[] cs = abbrev.toArray(new CharSequence[abbrev.length()]);
缩写只是将句子分成第一个字符 (Hello World --> 硬件)
String[] result = matches.toString().split("\\s+");
// The string we'll create
String abbrev = "";
// Loop over the results from the string splitting
for (int i = 0; i < result.length; i++){
// Grab the first character of this entry
char c = result[i].charAt(0);
// If its a number, add the whole number
if (c >= '0' && c <= '9'){
abbrev += result[i];
}
// If its not a number, just append the character
else{
abbrev += c;
}
}
有什么想法吗?
谢谢
【问题讨论】:
-
非常清晰的错误信息你有什么不明白的地方?
标签: android arrays charsequence