热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

android.view.KeyEvent.getAction()方法的使用及代码示例

本文整理了Java中android.view.KeyEvent.getAction()方法的一些代码示例,展示了KeyEvent.getAction()

本文整理了Java中android.view.KeyEvent.getAction()方法的一些代码示例,展示了KeyEvent.getAction()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyEvent.getAction()方法的具体详情如下:
包路径:android.view.KeyEvent
类名称:KeyEvent
方法名:getAction

KeyEvent.getAction介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
if (mWebView.canGoBack()) {
mWebView.goBack();
} else {
finish();
}
return true;
}
}
return super.onKeyDown(keyCode, event);
}

代码示例来源:origin: stackoverflow.com

public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event) {
if (actiOnId== EditorInfo.IME_NULL
&& event.getAction() == KeyEvent.ACTION_DOWN) {
example_confirm();//match this behavior to your 'Send' (or Confirm) button
}
return true;
}

代码示例来源:origin: stackoverflow.com

public boolean onKeyPreIme(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK &&
event.getAction() == KeyEvent.ACTION_UP) {
// do your stuff
return false;
}
return super.dispatchKeyEvent(event);
}

代码示例来源:origin: stackoverflow.com

builder.setNegativeButton("Refuse", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP)
finish();
return false;
}
});

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction()==KeyEvent.ACTION_DOWN) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_DOWN:
return(chooseNext());
case KeyEvent.KEYCODE_DPAD_UP:
return(choosePrevious());
}
}
return(false);
}
});

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction()==KeyEvent.ACTION_DOWN) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_DOWN:
return(chooseNext());
case KeyEvent.KEYCODE_DPAD_UP:
return(choosePrevious());
}
}
return(false);
}
});

代码示例来源:origin: stackoverflow.com

final EditText edittext = (EditText) findViewById(R.id.edittext);
edittext.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
// If the event is a key-down event on the "enter" button
if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
(keyCode == KeyEvent.KEYCODE_ENTER)) {
// Perform action on key press
Toast.makeText(HelloFormStuff.this, edittext.getText(), Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
});

代码示例来源:origin: stackoverflow.com

final EditText edittext = (EditText) findViewById(R.id.edittext);
edittext.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
Toast.makeText(HelloFormStuff.this, edittext.getText(), Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
});

代码示例来源:origin: rey5137/material

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP)
et_helper.setError("Password is incorrect.");
return false;
}

代码示例来源:origin: rey5137/material

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP)
et_helper_error.setError("Password is incorrect.");
return false;
}

代码示例来源:origin: smuyyh/BookReader

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
if (isVisible(llBatchManagement)) {
goneBatchManagementAndRefreshUI();
return true;
}
}
return false;
}
});

代码示例来源:origin: gzu-liyujiang/AndroidPicker

@Override
public final boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) {
onBackPress();
}
return false;
}

代码示例来源:origin: Bigkoo/Android-PickerView

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == MotionEvent.ACTION_DOWN && isShowing()) {
dismiss();
return true;
}
return false;
}
};

代码示例来源:origin: rey5137/material

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP){
String text = mPeriodEditText.getText().toString();
if(TextUtils.isEmpty(text))
mPeriodEditText.setText(String.valueOf(mRecurring.getPeriod()));
}
return false;
}
});

代码示例来源:origin: rey5137/material

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP){
String text = mEndNumEditText.getText().toString();
if(TextUtils.isEmpty(text))
mEndNumEditText.setText(String.valueOf(mRecurring.getEventNumber()));
}
return false;
}
});

代码示例来源:origin: k9mail/k-9

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
boolean ret = false;
if (KeyEvent.ACTION_DOWN == event.getAction()) {
ret = onCustomKeyDown(event.getKeyCode(), event);
}
if (!ret) {
ret = super.dispatchKeyEvent(event);
}
return ret;
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (event == null || event.getAction() == KeyEvent.ACTION_UP) {
searchFor(search.getText().toString());
InputMethodManager imm=
(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
return(true);
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (event == null || event.getAction() == KeyEvent.ACTION_UP) {
adapter.add(v.getText().toString());
v.setText("");
InputMethodManager imm=
(InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
return(true);
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (event == null || event.getAction() == KeyEvent.ACTION_UP) {
adapter.add(v.getText().toString());
v.setText("");
InputMethodManager imm=
(InputMethodManager)getActivity()
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
return(true);
}

代码示例来源:origin: smuyyh/BookReader

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) { // 表示按返回键
mWebView.goBack(); // 后退
// webview.goForward();//前进
return true; // 已处理
}
}
return false;
}
});

推荐阅读
author-avatar
阿宝宝86
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有