0

How to enable cursor for EditText if we already hide the soft keyboard. i done my code like that cursor blinking but cursor can't not perform cut/copy/paste and deleting character action.

I enable only cursor i done by using this code

EditText mEt = (EditText) findViewById(R.id.xEt);
if (Build.VERSION.SDK_INT >= 11) {

     mEt.setRawInputType(InputType.TYPE_CLASS_TEXT);
     mEt.setTextIsSelectable(true);

} else {

    mEt.setRawInputType(InputType.TYPE_NULL);
    mEt.setFocusable(true);

}

enter image description here

Mayank Patel
  • 3,868
  • 10
  • 36
  • 59
Attaullah
  • 3,856
  • 3
  • 48
  • 63

3 Answers3

0

Briefly, all you have to do is call:

editText.setRawInputType(InputType.TYPE_CLASS_TEXT);

for your EditText view (after you called ).

editText.setInputType(InputType.TYPE_NULL);

You should probably also set:

editText.setTextIsSelectable(true);
0

You can achieve this by using :

Edittext.setSelection(Edittext.length());

this will put the cursor position in the end. otherwise you can get the text in a string and check the text position where you want to put the cursor and do it like this

String text = edittext.gettext.tostring()

for(int i = 0; i <text.length();i++)
{
//your logic here to check the position of text
}

and then

Edittext.setSelection(position);

Reference link

Community
  • 1
  • 1
Kalu Singh Rao
  • 1,671
  • 1
  • 16
  • 21
0

You can use it :-)

editText.setCursorVisible(true);

Happy Coding :-)