安卓的EditText最大长度 [英] Android EditText Max Length

查看:137
本文介绍了安卓的EditText最大长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置文本​​的最大长度在一个EditText字段。

I set up a max length of text in an EditText field.

<EditText
            android:id="@+id/courseDescriptionField"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:inputType="textMultiLine"
            android:lines="5"
            android:maxLength="@integer/max_course_description_limit"
            android:gravity="left|top" >
        </EditText>

对我来说,问题不过是,是,文本停止后140个字符出现,但它仍不断输入,不同之处在于文本只是没有出现,但是但是,它会出现在缓冲(意的建议事),如果这就是你们所说的。

The problem for me however is, that, text STOPS appearing after 140 characters, but it still continues to type, except that text just doesn't appear, but however, it does appear in the "buffer" (meaning the suggestion thing) if that's what you would call it.

作为一个方面说明,我使用的是TextWatcher跟踪的限制。有没有什么办法可以完全限制的文本量,因此,当有140个字符,没有任何反应时的东西比其他退格键/删除是pressed?

As a side note, I am using a TextWatcher to keep track of the limit. Is there any way to completely limit the amount of text, so that when there are 140 characters, nothing happens when something other than backspace/delete is pressed?

推荐答案

中的的EditText在Android的限制文本长度

采用Android:最大长度=140

Use android:maxLength="140"

这应该工作。 :)

希望帮助

这篇关于安卓的EditText最大长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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