【发布时间】:2014-03-04 18:56:58
【问题描述】:
我遇到了这段代码的问题 - 它不应该添加重复的字符串,以防遇到一些。我不明白它为什么会崩溃。
Cursor people = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
NameIndex = people.getColumnIndex(PhoneLookup.DISPLAY_NAME);
Temp = people.getString(NameIndex);
myArr.add(Temp.toString());
while (people.moveToNext()) {
NameIndex = people.getColumnIndex(PhoneLookup.DISPLAY_NAME);
Name = people.getString(NameIndex);
if((Name.toString()).equals(Temp)) {
}
else {
myArr.add(Name.toString());
Temp = Name.toString();
}
}
【问题讨论】:
-
我没有找到从数组列表中删除元素的代码
-
它在哪里崩溃?你有一些 LogCat 输出要分享吗?
-
我们知道的比你还少,因为你没有提供任何细节或堆栈跟踪。此外,您没有遵循 Java 编码标准。
标签: java android android-listview arraylist