Android EditText Max Length(Android 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 个字符时,按下退格/删除以外的东西时什么都不会发生?
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?
推荐答案
限制Android中EditText的文本长度
使用 android:maxLength="140"
应该可以.:)
希望有帮助
这篇关于Android EditText 最大长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android EditText 最大长度
基础教程推荐
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 我的 UIImageView 的任务 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
