First letter capitalization for EditText(EditText 的首字母大写)
问题描述
我正在开发一个小型个人待办事项列表应用程序,到目前为止一切都运行良好.我想弄清楚一个小怪癖.每当我去添加一个新项目时,我都会有一个对话框,里面显示一个 EditText 视图.当我选择 EditText 视图时,键盘会按原样输入文本.在大多数应用程序中,默认值似乎是第一个字母的 shift 键......尽管在我看来它并没有这样做.必须有一种简单的方法来修复,但我反复搜索了参考资料,但找不到.我在想适配器加载的引用必须有一个 xml 属性,但我不知道它是什么.
静态(即在你的布局 XML 文件中):在你的 EditText 上设置 android:inputType="textCapSentences"代码>.
以编程方式:您必须在 EditText 的 InputType 中包含 InputType.TYPE_CLASS_TEXT,例如
EditText 编辑器 = new EditText(this);editor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);<块引用>
可以结合文本及其变体来请求每个句子的第一个字符大写.
- Google 文档
I'm working on a little personal todo list app and so far everything has been working quite well. There is one little quirk I'd like to figure out. Whenever I go to add a new item, I have a Dialog with an EditText view showing inside. When I select the EditText view, the keyboard comes up to enter text, as it should. In most applications, the default seems to be that the shift key is held for the first letter... although it does not do this for my view. There has to be a simple way to fix, but I've searched the reference repeatedly and cannot find it. I'm thinking there has to be an xml attribute for the reference loaded by the Adapter, but I can't find out what it is.
Statically (i.e. in your layout XML file): set android:inputType="textCapSentences" on your EditText.
Programmatically: you have to include InputType.TYPE_CLASS_TEXT in the InputType of the EditText, e.g.
EditText editor = new EditText(this);
editor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
Can be combined with text and its variations to request capitalization of the first character of every sentence.
- Google Docs
这篇关于EditText 的首字母大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:EditText 的首字母大写
基础教程推荐
- 我的 UIImageView 的任务 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
