【问题标题】:Edit text cursor not visible after setting SetCursorVisible(false) and click again设置 SetCursorVisible(false) 后编辑文本光标不可见并再次单击
【发布时间】:2016-06-08 18:39:52
【问题描述】:

我有一个要求,在编辑框中输入文本后,然后单击虚拟键盘 DONE(EditorInfo.IME_ACTION_DONE) 现在光标不可见 [我正在使用 editText.setCursorVisible(false)]。现在问题又是我单击编辑框光标不可见,但文本正在进入编辑框。

谢谢

【问题讨论】:

    标签: android layout android-edittext


    【解决方案1】:

    我通过使用解决了它

    edittext.setFocusableInTouchMode(true);//this brought back my cursor after setting focusable false.
    

    而不是

    edittext.setFocusable(true);
    

    【讨论】:

      【解决方案2】:

      您需要在 EditText 的 onClick 侦听器中再次设置光标可见。

      在您的 edittext onClick 监听器中尝试这两种方法。

      edittext.setFocusable(true);
      edittext.setCursorVisible(true); 
      

      这应该可以解决您的问题。

      【讨论】:

        【解决方案3】:

        将此属性放在edittext小部件中。

                android:cursorVisible="false"
        

        然后将此代码放在 mainactivity 的 oncreate() 中。

        Edittext searchView;
        searchView=(EditText)findViewById(R.id.editText);
        searchView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    searchView.setCursorVisible(true);
                    return false;
                }
            });
        

        注意::我已经为期货查询写了这个。希望这是我认为这个 qs 不需要的。

        【讨论】:

          【解决方案4】:

          也许会使视图无效?

          editText.invalidate()
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2014-02-14
            • 2017-10-31
            • 2012-04-14
            • 2016-03-17
            • 1970-01-01
            • 2013-11-17
            相关资源
            最近更新 更多