多行的EditText通过Done操作按钮

多行的EditText通过Done操作按钮

本文介绍了多行的EditText通过Done操作按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能有一个的EditText 小部件安卓inputType =textMultiLine组和安卓?imeOptions =actionDone同时

Is it possible to have an EditText widget with android:inputType="textMultiLine" set, and android:imeOptions="actionDone" at the same time?

我想多行编辑框,用键盘上的操作按钮来完成,而不是输入(回车),但它似乎并不奏效。

I'd like a multi-line edit box, with the action button on the keyboard to be Done, not Enter (Carriage Return), but it doesn't seem to be working..

在此先感谢

推荐答案

从Android文档:textMultiLine    普通文本的键盘,让用户的文字输入长串包含换行符(回车) 的完成按钮因此,如果你想拥有的textMultiLine属性是不恰当的在键盘

From the android documentation: '"textMultiLine" Normal text keyboard that allow users to input long strings of text that include line breaks (carriage returns).' Therefore the textMultiLine attribute is not appropriate if you want to have the 'Done' button in the keyboard.

一个简单的方式来获得的多线(在此情况下,3行)输入字段以完成按钮是使用的EditText以

A simple way to get a multi-line (in this case 3 lines) input field with the done button is to use EditText with

android:lines="3"
android:scrollHorizontally="false"

然而,由于某种原因,这只能通过

However, for some reason this only works for me if I do these settings in the code instead of the manifest (in onCreate) by

TextView tv = (TextView)findViewById(R.id.editText);
if (tv != null) {
    tv.setHorizontallyScrolling(false);
    tv.setLines(3);
}

我希望这可以帮助别人,因为它花了相当长一段时间才能体现出来。如果你找到一种方法,使其从工作清单,请告诉我们。

I hope this helps someone, as it took quite a while to figure out. If you find a way to make it work from the manifest, please let us know.

这篇关于多行的EditText通过Done操作按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 17:38