就像从sdcard读取一个txt文件一样,逐一取出每个单词,然后对提取的单词做一些事情。 像
String mm = blure.getAbsolutePath();
StringBuilder text = new StringBuilder();
try {
BufferedReader br = new BufferedReader(new FileReader(mm));
String line;
while((line = br.readLine()) != null) {
text.append(line);
text.append('\n');
然后有些东西可以得到每一个字,并用它做点什么。
答案 0 :(得分:3)
这可以像这样实现
editText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.toString().contains("my")) {
//do something
}
else
//do something
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
答案 1 :(得分:1)
实施EditText.OnEditorActionListener
public boolean onEditorAction(TextView textView, int action, KeyEvent keyEvent)