如何在android系统上的EditText点击时显示自定义键盘 [英] How to display custom keyboard when clicking on edittext in android

查看:906
本文介绍了如何在android系统上的EditText点击时显示自定义键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序的自定义键盘。问题是如何当上点击edittext.I的使用setonfocuschangre监听器,现在看来custon keyboaed展架这款键盘时的EditText焦点changed.but我想说明这个键盘每当我在edittext..one信息,我忘了点击把这里的EditText是片段中。

I have a custom keyboard in my application. question is How to didplay this keyboard when click on the edittext.I an using setonfocuschangre listener ,now the custon keyboaed appears when the edittext focus is changed.but i want to show this keyboard whenever i click on the edittext..one info I forget to put here the edittext is within the fragment.

推荐答案

您可以尝试这样的事情

    edittext.setOnClickListener(new OnClickListener() {
                    // NOTE By setting the on click listener, we can show the custom keyboard again,
                   // by tapping on an edit box that already had focus (but that had the keyboard hidden).
                    @Override public void onClick(View v) {
                        showCustomKeyboard(v);
                    }
          });


          // Disable standard keyboard hard way
          // NOTE There is also an easy way: 'edittext.setInputType(InputType.TYPE_NULL)' 
         // (but you will not have a cursor, and no 'edittext.setCursorVisible(true)' doesn't work )
                edittext.setOnTouchListener(new OnTouchListener() {
                    @Override public boolean onTouch(View v, MotionEvent event) {
                        EditText edittext = (EditText) v;
                        int inType = edittext.getInputType();       // Backup the input type
                        edittext.setInputType(InputType.TYPE_NULL); // Disable standard keyboard
                        edittext.onTouchEvent(event);               // Call native handler
                        edittext.setInputType(inType);              // Restore input type
                        return true; // Consume touch event
                    }
                });


        // Disable spell check (hex strings look like words to Android)
        edittext.setInputType(edittext.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

有关详细信息查询这里

这篇关于如何在android系统上的EditText点击时显示自定义键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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