Android EditText:完成而不是Enter或自动换行而不是Multi Line [英] Android EditText: Done instead of Enter or Word Wrap instead of Multi Line

查看:770
本文介绍了Android EditText:完成而不是Enter或自动换行而不是Multi Line的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多行EditText,不允许返回行.现在,一旦单击保存,我将用一些空格替换退货.有什么办法可以用完成按钮替换屏幕上的输入按钮? (就像单行EditText一样)

I have a multiple line EditText that does not permit line returns. Right now I am replacing returns with some spaces as soon as they click save. Is there any way I can replace the on screen enter button with a Done button? (like it is for single line EditText)

我知道我仍然应该去除收益(\r\n|\r|\n),因为屏幕键盘不是添加收益的唯一方法.

I am aware that I should still strip out returns (\r\n|\r|\n) because the on screen keyboard is not the only way to add them.

这是我当前的XML

<EditText android:layout_width="fill_parent" android:layout_height="wrap_content"
          android:minLines="3" android:gravity="left|top"
          android:inputType="textMultiLine|textAutoCorrect|textCapSentences"
          android:imeOptions="actionDone" />

推荐答案

android:inputType="textEmailAddress|textEmailSubject"

您需要将输入类型设置为电子邮件地址或电子邮件主题.任一种都会给您您想要的结果. shouldAdvanceFocusOnEnter()是TextView中的私有方法,用于确定是输入新行还是将焦点移至下一个字段.

You need to set the input type as email address or email subject. Either one will give you your desired result. shouldAdvanceFocusOnEnter() is a private method in TextView which determines whether to enter a new line or move focus to next field.

这篇关于Android EditText:完成而不是Enter或自动换行而不是Multi Line的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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