Android的执行后,pressing&QUOT功能; Enter]键。为的EditText [英] Android execute function after pressing "Enter" for EditText

查看:147
本文介绍了Android的执行后,pressing&QUOT功能; Enter]键。为的EditText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在关注官方Android教程,不知怎么我有与这个非常简单的例子来执行功能后,pressingENTER键一个EditText。

I have been following the official Android tutorials and somehow am having a problem with this very simple example to execute a function after pressing "Enter" for an EditText.

我明白我应该做的,而且似乎拥有一切设置正确,但是Eclipse抱怨这一行:

I understand what I'm supposed to do and seem to have everything setup properly, but Eclipse is complaining with this line:

edittext.setOnKeyListener(new OnKeyListener() {

它强调 setOnKeyListener ,出现错误:

在类型视图的方法setOnKeyListener(View.OnKeyListener)不适用于参数(新DialogInterface.OnKeyListener(){})

The method setOnKeyListener(View.OnKeyListener) in the type View is not applicable for the arguments (new DialogInterface.OnKeyListener(){})

和还强调 OnKeyListener ,出现错误:

该型新DialogInterface.OnKeyListener(){}必须实现继承的抽象方法DialogInterface.OnKeyListener.onKey(DialogInterface,INT,KeyEvent的)

The type new DialogInterface.OnKeyListener(){} must implement the inherited abstract method DialogInterface.OnKeyListener.onKey(DialogInterface, int, KeyEvent)

也许有人可以拍我在正确的方向?之前我尝试其他解决方案(这是我的计算器已经找到),我真的很想弄清楚这一点,因为它有我心慌的东西这么简单跟随,作为正式的教程,似乎没有工作。

Perhaps someone can shoot me in the right direction? Before I try other solutions (which I've already found on stackoverflow), I'd really like to figure this out because it has me flustered that something so simple to follow, as an official tutorial, doesn't seem work.

在此先感谢。

推荐答案

这是我所看到的,它看起来像你有错误的导入。

From what I can see, It looks like you have the wrong import.

尝试

edittext.setOnKeyListener(new View.OnKeyListener() {

或添加此导入

OR add this import

import android.view.View.OnKeyListener;

和删除这个

import android.content.DialogInterface.OnKeyListener;

这篇关于Android的执行后,pressing&QUOT功能; Enter]键。为的EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆