-3
möchte ich sagen, ‚Suche nach dem Namen des Benutzers oder die Anzahl der Benutzer, aber das funktioniert nicht:Benötigen Sie Hilfe mit Android || Betreiber
if (wp.getName().toLowerCase(Locale.getDefault())
.contains(charText)) || (wp.getPhone().toLowerCase(Locale.getDefault())
.contains(charText))
Alle Ideen, wie ich diese Arbeit zu bekommen? Hier ist mein vollständiger Code:
public void filter(String charText) {
charText = charText.toLowerCase(Locale.getDefault());
// _data is our list of contacts
_data.clear();
// If there is nothing in the searchview, if the charText length is 0,
// then show all the contacts
if (charText.length() == 0) {
_data.addAll(arraylist);
// or else....
} else {
for (SelectContact wp : arraylist) {
// If a contact's name matches the input thus far, which is charText, or their number matches it,
// then include it in the listview.
if (wp.getName().toLowerCase(Locale.getDefault())
.contains(charText)) || (wp.getPhone().toLowerCase(Locale.getDefault())
.contains(charText))
{
_data.add(wp);
}
}
}
notifyDataSetChanged();
}
fügen Sie alle Ihre wenn condidtion in Klammern 'if ((...) || (...))'. Jetzt ist es 'if (...) || (...) ', das wird nicht funktionieren. –