我有这样的代码,其搜索的字符串数组,如果输入的字符串相匹配的字符串的第一个字符,返回结果:如何搜索整个字符串的特定单词?
for (int i = 0; i < countryCode.length; i++) {
if (textlength <= countryCode[i].length()) {
if (etsearch
.getText()
.toString()
.equalsIgnoreCase(
(String) countryCode[i].subSequence(0,
textlength))) {
text_sort.add(countryCode[i]);
image_sort.add(flag[i]);
condition_sort.add(condition[i]);
}
}
}
但我想那些字符串也是在输入字符串不仅在比赛中第一个字符,但也在字符串中的任何位置?这个怎么做?
String有一个contains()方法 - 可以使用它。 – mcfinnigan
是否可以在android中使用String.indexOf()? – Teg
contains,indexOf()没有任何工作适合我:( – Reyjohn