如何在Android应用程序的TextView中大写字母的首字母 [英] How to capitalize the first letter of text in a TextView in an Android Application
本文介绍了如何在Android应用程序的TextView中大写字母的首字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我也不是指textInput.我的意思是,一旦您在TextView中拥有静态文本(从数据库调用填充到用户输入的数据(可能不会大写)),如何确保它们大写?
I'm not referring to textInput, either. I mean that once you have static text in a TextView (populated from a Database call to user inputted data (that may not be Capitalized)), how can I make sure they are capitalized?
谢谢!
推荐答案
我应该能够通过标准的Java字符串操作来完成此操作,而无需Android或TextView专用.
I should be able to accomplish this through standard java string manipulation, nothing Android or TextView specific.
类似的东西:
String upperString = myString.substring(0, 1).toUpperCase() + myString.substring(1).toLowerCase();
尽管有大约一百万种方法可以完成此任务.请参阅 String 文档.
Although there are probably a million ways to accomplish this. See String documentation.
已编辑我添加了 .toLowerCase()
这篇关于如何在Android应用程序的TextView中大写字母的首字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文