如何使EditText显示输入字母或字符串

时间:2012-08-19 19:54:19

标签: android android-edittext

我在android的edittext控件中面临一个奇怪的问题。

问题是,当我在软键盘中键入任何内容时。文本未在编辑框中打印。

这是代码

mEditview.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                public void onFocusChange(View v, boolean hasFocus) {
                    if (hasFocus) {
                           InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                           imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
                    }
                }
            });
            mEditview.requestFocus();

添加了布局代码

    <?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/filter_text"
    android:imeOptions="actionDone"
    android:singleLine="true"
    android:hint="Search"/>

以下是我在模拟器中输出的内容。它为什么会这样?如何解决这个问题

enter image description here

0 个答案:

没有答案
相关问题