EditText上的onClick不会显示虚拟键盘 [英] EditText onClick not shows Virtual Keyboard

查看:349
本文介绍了EditText上的onClick不会显示虚拟键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我点击我的EditText,虚拟键盘简单的不能显示出来。已显示光标,但没有键盘上键入。

If i click on my EditText, the virtual keyboard simple not shows up. The cursor is shown, but no keyboard to type on.

我甚至尝试用手动打开,但只是没有工作。

I even tried it with manually open but just no works.

下面是我的code:

public class CreateNote extends Activity {
EditText titleEdit;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.createnote);
    titleEdit = (EditText) findViewById(R.id.titleEdit);
    titleEdit.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            InputMethodManager imm = (InputMethodManager) CreateNote.this
                    .getSystemService(Service.INPUT_METHOD_SERVICE);
            imm.showSoftInput(titleEdit, 0);
        }
    });
    }
   }

布局的代码段:

Snippet of Layout:

 <FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#989898" >

    <EditText
        android:id="@+id/titleEdit"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/edittextdrawale"
        android:ems="10"
        android:textColor="#fff"
        android:textColorHint="#fff" >

        <requestFocus />
    </EditText>

</FrameLayout>

有什么能玩捉迷藏的原因,寻求我的虚拟键盘? 我测试在真实的设备,而不是模拟器。

What could be the reason of playing hide and seek of my virtual keyboard ? I test on real device, not on emulator.

推荐答案

试试这个,它为我工作。

Try with this, it worked for me.

EditText etHorseName = (EditText) getView().findViewById(R.id.horseName);
etHorseName.clearFocus();

的onCreate()或你想要的。

这篇关于EditText上的onClick不会显示虚拟键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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