1

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

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

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

谢谢

这是一个展示卡住的大写行为的代码片段。我无法想象我是唯一遇到过这个问题的人。

单击地址行 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>
4

1 回答 1

0

If you want to show a keyboard with Capital case then instead of using android:inputType="textCapCharacters", you can use android:textAllCaps="true". Then your won't stick to the Uppercase format. Then to be sure that the input is in Uppercase, you can just call the toUpperCase() method on the retrieved String from the EditText. Let me know your thoughts on this. Check this link for more clarity.

于 2016-02-25T08:41:25.007 回答