【问题标题】:Uppercase getting stuck on for Android EditText control大写卡在 Android EditText 控件上
【发布时间】:2011-10-03 03:28:17
【问题描述】:

我有一个布局,我将 EditText 控件的输入类型设置为 android:inputType="textCapCharacters"。在此控件上运行良好,但随后会继续使用,甚至将大写属性传递给其他应用程序。

这似乎是 2.1 英雄和 2.3 野火的情况。

关于如何解开它或将键盘设置回默认模式的任何建议?

谢谢

这是一个代码 sn-p,它展示了卡住的大写行为。我无法想象我是唯一遇到过这个问题的人。

点击地址行 1,大写的单词可以正常工作。聚焦邮政编码时,键盘正确切换为大写,但无论您关注什么其他控件(例如,单击返回地址行 1),即使您转到另一个应用程序,键盘仍会停留在大写状态。

应该注意的是,代码在模拟器中似乎可以正常工作,并且它只在物理设备上以大写形式锁定。

我现在知道,至少在 Hero 上,问题只存在于普通键盘上。使用 swiftkey 键盘时,一切似乎都很好。

我已经在另外两个论坛上发布了这个问题,但没有任何回应,但 Stackoverflow 似乎是此类查询的最佳推荐,但 8 天后,我也没有关于我可以在这里尝试什么的建议。如果更多信息、不同标签或在其他地方发布对我来说是更好的选择,我也很乐意听到这些建议。

显示错误的完整代码如下。

有什么建议吗?

import android.app.Activity;
import android.os.Bundle;

public class Main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent" android:layout_width="fill_parent">



    <TableLayout android:layout_width="fill_parent" android:id="@+id/tableLayout1"
        android:layout_height="fill_parent" android:layout_margin="5dp"
        android:stretchColumns="1">

        <TableRow>
            <EditText android:textSize="17sp" android:layout_height="39dp"
                android:layout_width="fill_parent" android:id="@+id/address"
                android:hint="Address Line 1" android:layout_span="3"
                android:inputType="textCapWords"></EditText>
        </TableRow>

        <TableRow>
            <EditText android:inputType="textCapCharacters"
                android:textSize="17sp" android:id="@+id/postcode"
                android:layout_height="39dp" android:hint="Postcode"
                android:layout_weight="1" android:layout_width="0dip"></EditText>
            <CheckBox android:text="Check Me"
                android:layout_height="39dp" android:id="@+id/checkme"
                android:textSize="12sp" android:layout_weight="1"
                android:layout_span="2" android:layout_width="0dip"
                android:layout_gravity="center"></CheckBox>
            <TextView android:layout_weight="1" android:layout_width="0dip"></TextView>
        </TableRow>
    </TableLayout>
</LinearLayout>

【问题讨论】:

  • 遇到同样的问题,未找到解决方案 :(

标签: android android-layout android-edittext uppercase


【解决方案1】:

如果你想显示一个大写的键盘,那么你可以使用android:textAllCaps="true",而不是使用android:inputType="textCapCharacters"。那么你就不会坚持使用大写格式。然后为了确保输入是大写的,您可以对从 EditText 检索到的字符串调用 toUpperCase() 方法。让我知道你对此的看法。 Check this link for more clarity.

【讨论】:

    猜你喜欢
    • 2012-03-12
    • 1970-01-01
    • 2013-04-04
    • 1970-01-01
    • 1970-01-01
    • 2012-09-30
    • 2020-03-14
    • 2020-07-06
    • 1970-01-01
    相关资源
    最近更新 更多