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.
当前回答
在XML编辑文本中应用以下行。
android:inputType="textCapSentences|textMultiLine"
它还允许多线支持。
其他回答
以编程方式
TextView firstline = (TextView) findViewById(R.id.firstline);
firstline.setAllCaps(true);
只需在EditText元素中使用android:inputType="textCapWords"即可。
例如:
<EditText
android:id="@+id/txtName"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="0.7"
android:inputType="textCapWords"
android:textColorHint="#aaa"
android:hint="Name Surname"
android:textSize="12sp" />
请参考以下链接: http://developer.android.com/reference/android/widget/TextView.html#attr_android%3ainputType
对于EditText中的资本化,您可以选择以下两种输入类型:
android:inputType=“textCapSentences” android:inputType=“textCapWords”
textCapSentences 这将使每个句子中第一个单词的第一个字母成为大写字母。
textCapWords 这将使每个单词的第一个字母作为大写字母。
如果你想要两个属性都使用|符号
android:inputType="textCapSentences|textCapWords"
我也遇到了同样的问题,只是分享了我的发现。可能会帮助你和其他人…
在你的布局上试试这个。在EditText中添加下面的行。
android:inputType="textCapWords|textCapSentences"
对我来说很好..希望它也适用于你…
在你的布局XML文件中:
将android: inputType = " textCapSentences " 在您的EditText中,将每个句子的第一个单词的首字母作为大写 或者android:inputType="textCapWords"在你的EditText有第一个字母的每个单词作为资本
推荐文章
- apk (.apk)和应用程序包(.aab)的区别
- 如何设置超时在改造库?
- Android - SPAN_EXCLUSIVE_EXCLUSIVE跨度不能为零长度
- TextView的字体大小在Android应用程序改变字体大小从本机设置
- 如何模拟Android杀死我的进程
- 禁用EditText闪烁光标
- Android Eclipse -无法找到*.apk
- 设置TextView文本从html格式的字符串资源在XML
- 如何允许所有网络连接类型HTTP和HTTPS在Android(9)馅饼?
- Android加载JS包失败
- Android Studio, logcat在应用程序关闭后清理
- 在android中从上下文获取活动
- 无法解析主机"<URL here>"没有与主机名关联的地址
- getActivity()在Fragment函数中返回null
- 按钮背景是透明的