如何在Android上设计一个这样的EditText:用户不用使用回车或换行符输入一个多行文本,但是文本显示依然是多行,即有自动换行。
类似于内置的SMS应用程序,我们不需要输入换行符但文本是多行显示的。
避免在EditText中输入回车键但文本依然是多行显示
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
4条回答
- balmy 2012-11-27 13:54关注
你说的sms中的效果实现代码是这个,可以参考下,要实现 TextView.OnEditorActionListener这个接口,机关就在这个方法里,具体也可参考 Mms源码 composeMessageActivity.java
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (event != null) { // if shift key is down, then we want to insert the '\n' char in the TextView; // otherwise, the default action is to send the message. if (!event.isShiftPressed()) { if (isPreparedForSending()) { //confirmSendMessageIfNeeded(); showDialog(SIM_CARD_CHOOSER_ID, null); } return true; } return false; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报