Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
edittext があり、その中の単語を数えたいと思います。edittext に新しい行がある場合、何か問題があります。
私はこれを試しました:
String[] WC = et_note.getText().toString().split(" "); Log.i("wordcount", "wc: " + WC.length);
これはテキストです -> wc: 4
これは
a
テキスト -> トイレ: 4
シンプルな
何か案は?
スペース文字だけでなく、空白の任意の文字列で分割したい。したがって、.split("\\s+")代わりに使用し.split(" ")ます。
.split("\\s+")
.split(" ")