final EditText et = (EditText) findViewById(R.id.EditText01);
<span style="white-space:pre"> </span>et.setOnKeyListener(new View.OnKeyListener() {
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>@Override
<span style="white-space:pre"> </span>public boolean onKey(View v, int keyCode, KeyEvent event) {
<span style="white-space:pre"> </span>//监视硬键盘按键
<span style="white-space:pre"> </span>if(event.getAction()== KeyEvent.ACTION_DOWN && keyCode==
KeyEvent.KEYCODE_ENTER){
<span style="white-space:pre"> </span>//按住把EditView中的文版显示在吐司消息中
<span style="white-space:pre"> </span>Toast.makeText(MainHelloEditView.this, et.getText(),
<span style="white-space:pre"> </span>Toast.LENGTH_SH
Android 控件之三:EditView 可编辑文本框
最新推荐文章于 2023-07-14 15:21:21 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)