2016-04-20 21 views
-3
私は、ユーザーの名前やユーザーの数を検索」、言いたい

が、これは動作しません:私はこの作業を得ることができる方法についてのAndroidのサポートが必要です||オペレータ

if (wp.getName().toLowerCase(Locale.getDefault()) 
    .contains(charText)) || (wp.getPhone().toLowerCase(Locale.getDefault()) 
    .contains(charText)) 

任意のアイデア?ここに私の完全なコードは次のとおりです。

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(); 
     } 
+2

のように括弧内のすべてのあなたの場合condidtionを囲み、括弧であなたの場合の条件の全体を囲み、上記の彼のコメントで指摘したように'if((... ...)||(...))'。今は 'if(...)|| (...) '、これは動作しません。 –

答えて

1

ボブMaloogaは常にこの

if (put the whole condition of what your looking out for in here) 
{do stuff} 
関連する問題