1
我想知道屏幕上的觸摸是在Android鍵盤上還是在屏幕上。我認爲代碼中應該有一些參數來確定用戶是否觸摸了任何輸入法或者只是正常滾動如何查找觸摸事件是否處於輸入法或其他方式?
我想知道屏幕上的觸摸是在Android鍵盤上還是在屏幕上。我認爲代碼中應該有一些參數來確定用戶是否觸摸了任何輸入法或者只是正常滾動如何查找觸摸事件是否處於輸入法或其他方式?
據我所知,你必須使用TextWatcher並在你的最後測試,如果用戶輸入一些東西,然後做你的東西,其他明智的用戶點擊其他屏幕。
edittext.addTextChangedListener(mTextEditorWatcher);
private final TextWatcher mTextEditorWatcher = new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
public void onTextChanged(CharSequence s, int start, int before, int count)
{
}
public void afterTextChanged(Editable s)
{
};
或
You have to implement below code on your java class:-
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_2){
// your stuff here
}
return super.onKeyDown(keyCode, event);
}