软键盘燮preSS外观上的EditText焦点 [英] Suppress appearance of the soft keyboard on EditText focus

查看:181
本文介绍了软键盘燮preSS外观上的EditText焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图定义一组按钮,允许用户将数据输入到一个EditText框。我想一个EditText框的所有默认功能,除了软键盘的弹出。被允许的唯一数据,进入的EditText框应该从我已经定义的按钮的数据。我试图通过捕捉触摸事件,并返回true共进晚餐preSS软键盘。 (每谈话在此线程找到)

 私人OnTouchListener txtTouchListener =新OnTouchListener()
    {
    @覆盖
    公共布尔onTouch(视图V,MotionEvent事件)
        {
        //返回true共进晚餐preSS事件的传递到OS
        返回true;
        }
    };

问题是,那么这种方法阻止发射的长按事件。为了解决这个问题,我可以返回false,然后处理长按事件。然而,这则使得短按一下弹出软键盘。此外,在长按的不仅是软键盘燮pressed,但这样是上下文菜单。我正在寻找一种方式出现在短期(或长期)点击,但保留其他所有功能停止键盘(更新短点击光标位置,对长按表演的EditText上下文菜单等)

在这个任何想法是极大的AP preciated!


解决方案

线程建议

  EditText.setInputType(InputType.TYPE_NULL);


  

或者你设置 inputType下在XML属性为


没有尝试过自己,但。

I am trying to define a set of buttons that allow the user to enter data into an EditText box. I want all the default functionality of an EditText box except for the pop up of the soft keyboard. the only data to be allowed to enter into the EditText box should be the data from the buttons I have defined. I am trying to suppress the soft keyboard by catching the touch event and returning true. (per the conversation found on this thread)

private OnTouchListener txtTouchListener = new OnTouchListener()
    {
    @Override
    public boolean onTouch(View v, MotionEvent event)
        {
        //Return true to suppress the passing of the event on to the OS
        return true;
        }
    };

The problem is that this method then blocks the long click event from firing. To solve this I can return false and then handle the long click event. However, this then makes the short click bring up the soft keyboard. Also, upon long click not only is the soft keyboard suppressed, but so is the context menu. I am looking for a way to stop the keyboard from appearing on a short (or long) click but keep all other functionality (updating the cursor position on short click, on long click show the EditText context menu, etc.)

Any ideas on this is greatly appreciated!

解决方案

This thread suggests:

EditText.setInputType(InputType.TYPE_NULL);

Or you set the inputType in the XML Attribute to none.

Not tried it myself though.

这篇关于软键盘燮preSS外观上的EditText焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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