android - android :inputType of EditText View set to "numberDecimal"时接受SIP输入的数字和字母

标签 android input keyboard android-edittext sip

加载 View 时,我想强制 SIP 打开并显示带有数字的键盘。另外,我想要一个 editText View 接受来自 SIP 的字母和数字输入

XML
            <EditText android:id="@+id/search_bus_by_num_keyword"
            android:layout_height="wrap_content" android:layout_width="fill_parent"
            android:lines="1" android:layout_weight="1"
            android:inputType="numberDecimal"
            />

Code
    editTextSearchKeyword = (EditText) context.findViewById(R.id.search_bus_by_num_keyword);
    editTextSearchKeyword.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) 
        {
            // If the event is a key-down event on the "enter" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
                    (keyCode == KeyEvent.KEYCODE_ENTER)) {
                // Perform action on key press
                context.hideSIP(editTextSearchKeyword);
                searchRoute();
                return true;
            }
            return false;
        }
    });
    editTextSearchKeyword.setText(searchKeyword);

    editTextSearchKeyword.requestFocus();
    InputMethodManager mgr = (InputMethodManager) context.getSystemService(context.INPUT_METHOD_SERVICE);
    mgr.showSoftInput(editTextSearchKeyword, InputMethodManager.SHOW_FORCED);

加载 View 时: http://pwong.name/sip_01.png

当我将 SIP 从数字更改为字母时: http://pwong.name/sip_02.png ,我无法将 Letter 输入到 editText View 。

如果我将 android:inputType="numberDecimal"设置为 editText,是否可以同时输入数字和字母?是否可以在运行时更改 android:inputType?

最佳答案

参见 this关于如何在代码中更改 InputType 的问题。参见 this EditText 输入类型的链接。至于你的要求“我想强制 SIP 打开并显示带数字的键盘。另外,我想要一个 editText View 接受来自 SIP 的字母和数字输入”——我不明白。我认为 EditText 不能有多种输入模式。

关于android - android :inputType of EditText View set to "numberDecimal"时接受SIP输入的数字和字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6985241/

相关文章:

Android:响应项目点击的多个gridView行

AndroidJUnit4.class 已弃用 : How to use androidx. test.ext.junit.runners.AndroidJUnit4?

android - 无法运行从 Github 导入的项目

javascript - 仅当每个输入都为空时才验证表单

iphone - 为电话号码文本字段设置适当的键盘

java - File() 构造函数中是否需要 .txt 扩展名?

Shell 脚本用户提示/输入

ios - ionic 2 导入 ionic 插件键盘不工作

windows - 如何制作自定义键盘布局?

c - 从 C 文件中获取输入