EditText上与单个文本行,换行和完成动作? [英] EditText with single text line, line wrapping and Done action?

查看:195
本文介绍了EditText上与单个文本行,换行和完成动作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用软键编辑时,有一个的EditText 具有以下特点。我准备好资料,在这里搜索带有参数玩,但一直没找到工作配置。

I am trying to have an EditText with the following characteristics when editing with a soft key. I ready the documentation, searched here, play with the parameters but could not find a working configuration.

  1. 在屏幕上的 EditView中视图具有高度的几行(例如3-4)。
  2. 内容文本是一个单行(即,没有换行符)。
  3. 如果内容文本的长度超过视图的宽度应该换到下一行
  4. 软键的回车键表示完成动作的标签。
  1. The EditView view on the screen has height for a few lines (e.g. 3-4).
  2. The content text is a single line (that is, no line breaks).
  3. If the content text is longer than the view's width it should wrap to next line
  4. The Enter key of the soft key shows the Done action label.

我能达到{1,2,3}和{1,2,4},但没有{1,2,3,4}。我的合理的是,由于内容是一行(不换行符)回车键没有使用,因此应能够被改变到完成标签

I could achieve {1,2,3} and {1,2,4} but not {1,2,3,4}. My rational is that since the content is a single line (no line breaks) the Enter key is not used and thus should be able to be changed to the Done label.

我的设置code看起来像这样

My setup code looks like this

editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
editText.setHorizontallyScrolling(false);
editText.setSingleLine(false);
// This does not work. Soft keyboard has Enter action.
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);

这可能吗?任何建议?

Is it possible? Any suggestion?

推荐答案

该组合(的的EditText 方法调用特定的顺序)应该产生所需的配置

This combination (and the specific order of the EditText method calls) should produce the configuration that you want:

  editText.setInputType(
    InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
  editText.setSingleLine(true);
  editText.setLines(4); // desired number of lines
  editText.setHorizontallyScrolling(false);
  editText.setImeOptions(EditorInfo.IME_ACTION_DONE);

这篇关于EditText上与单个文本行,换行和完成动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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