![](/img/trans.png)
[英]Android keyboard only shows up once, but works perfectly when I remove the ListView
[英]KeyEvent.ACTION_UP only works when I use computer keyboard but not works in android virtual keyboard
我想在 webview 中搜索單詞。 因此,在 android 仿真器中,當我在鍵入時使用計算機鍵盤輸入 edittext 內容時,搜索將開始查找單詞。 但是當我在模擬器或真實設備中使用 android 鍵盤時沒有任何反應,不會搜索單詞。
if ((event.getAction() == KeyEvent.ACTION_UP) || ((keyCode == KeyEvent.KEYCODE_ENTER)))
{
myWebView.findAllAsync(findBox.getText().toString());
任何想法如何解決?
所以基本上如果你使用的是編輯文本框
EditText mEditText = (EditText) findViewById(R.id.edit_text);
mEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (editable.length() != 0) {
// save the content here
}
}
});
如需進一步閱讀,請閱讀此
將它與您的編輯文本字段一起使用,基本上,它會偵聽除按鍵操作之外的任何文本更改! 干杯!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.