2016-07-27 17 views
-1

こんにちは私は以下のコードを持っていて、文字列 "メッセージ"にファルシ文字が含まれていてもトーストを使ってメッセージを表示したいが、私のコード? ありがとうございます!ここ文字列配列でアンドロイドで検索

if(message.contains(chr[j])); 

P.Sから

int len=message.length(); 
           final String [] chr={ "چ","ج","ح","خ","ه","ع","غ","ف","ق","ث","ص","ض", 
                "ش","س","ی","ب","ل","ا","ت","ن","م","ک","گ","ظ","ط","ز", 
                "ر","ذ","د","ئ","و","?","آ","ژ","پ","ء","،","ۀ","؛", 
                "ٌ","'ً","آ","ِ","ُ","َ","ة","ي","ؤ","إ","أ" }; 


            for(int i=0;i<len;i++) 
            { 

             for(int j=0;j<49;j++) 
             { 
              if(message.contains(chr[j])); 
              { 
               EnglishSms="false"; 
               Toast.makeText(getApplicationContext(), chr[j], Toast.LENGTH_LONG).show(); 
              // break; 
              } 
             } 
            } 
+0

なぜ2つのforループがありますか?長さは何ですか?あなたの質問 –

+0

を詳しく説明してください。これは、 "for(int j = 0; j <49; for(int i = 0; i

答えて

2

削除セミコロン:これだけはトリックを行うだろう

for(int j=0;j<49;j++) { 
    if(message.contains(chr[j])) 
    { 
     EnglishSms="false"; 
     Toast.makeText(getApplicationContext(), chr[j], Toast.LENGTH_LONG).show(); 
     break; 
    } 
} 
0
String message = "TheMessageToCheckWith"; 
final String [] chr={ "چ","ج","ح","خ","ه","ع","غ","ف","ق","ث","ص","ض", 
     "ش","س","ی","ب","ل","ا","ت","ن","م","ک","گ","ظ","ط","ز", 
     "ر","ذ","د","ئ","و","?","آ","ژ","پ","ء","،","ۀ","؛", 
     "ٌ","'ً","آ","ِ","ُ","َ","ة","ي","ؤ","إ","أ" }; 

for(int i = 0; i < chr.length; i++) { 
    if(message.contains(chr[i])) { 
    //TODO: Show Toast 
    //Break; 
    } 
} 

は少しあなたのためのコードを変更しました。

+0

ありがとうございました。 –

関連する問題