简体   繁体   English

在TextView中按Enter时,单击按钮?

[英]When pressing enter inside TextView, click button?

I have a text view (and possibly 1 or 2 Spinners after it) and a Button. 我有一个文本视图(可能还有1或2个微调框)和一个按钮。 When a user presses the enter key (soft or hard keyboard), I want to Click the Search button, which is next. 当用户按下Enter键(软键盘或硬键盘)时,我要单击“ 搜索”按钮,其次是。

Is it only possible to do this by overriding the onKey event of the TextView and when Enter is pressed, performClick() the Button? 是否只能通过重写TextView的onKey事件来执行此操作,并且在按Enter键时,执行Button的performClick()?

I can't find much information from Google, but i could be searching for the wrong term. 我从Google找不到太多信息,但是我可能正在搜索错误的术语。

Cheers, D 干杯,D

是的,这只能通过重写onKey事件来实现。

为什么不直接从TextField的onClick方法执行按钮单击触发的操作?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM