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 的首字母大写


- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01