Android大写字母无法在手机中使用 [英] Android Capitalize characters not working in phone

查看:111
本文介绍了Android大写字母无法在手机中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,我想允许用户仅输入大写字母。所以我用大写的财产。

in my app, I want to allow the user to enter only upper case letters. So I used capitalize property.

这是代码的一部分

<EditText
    android:id="@+id/et5"
    android:layout_width="140dp"
    android:layout_height="wrap_content"
    android:layout_x="127dp"
    android:layout_y="219dp"
    android:maxLength="25"
    android:ems="10"
    android:singleLine="true"
    android:capitalize="characters"
    android:text="" />

在某些情况下,我也尝试过此操作

In some cases I also tried this

android:inputType="textCapCharacters"

在模拟器,但无法在电话中使用。在电话中,它显示小写字母。

It works fine in emulator, But it is not working in phone. In phone, it shows lower case letters. What is the mistake here and how to overcome?

推荐答案

尝试一下:

editText.setFilters(new InputFilter[] {new InputFilter.AllCaps()});

并将EditText xml属性设置为:

and set EditText xml property to:

android:inputType="text|textCapCharacters"

希望它帮助:)

这篇关于Android大写字母无法在手机中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆