Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Edit Text Cursor Doesn't Appear

in my app I disabled the keyboard (I use now my custom keyboard) using this code:

editText.setInputType(InputType.TYPE_NULL);

Now, my problem is that the text cursor does not appear anymore in the edit text. What should I do? Any suggestion would be very appreciated.

like image 885
Laura Avatar asked Jan 11 '13 16:01

Laura


People also ask

How do I turn off edit text on android?

To disable an EditText while keeping this properties, just use UI. setReadOnly(myEditText, true) from this library. If you want to replicate this behaviour without the library, check out the source code for this small method.

How do I change the icon on an edited text?

2- First thing we need to do is to look for icons that we can use them for the android edittext. Right click on res folder → New → Vector Asset . Adjust the size from (24dp x 24dp) to (18dp x 18dp), choose the icon that you want by clicking on the android icon, click “Next” button and then click “Finish”.


1 Answers

There is an Issue opened in bug tracker Issue opened in bug tracker for this. One of the users suggests the approach which works on "most" devices.

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);

in order for text to be selectable (though in does not seem to work properly with Samsung Galaxy SIII). This method is only available starting from HONEYCOMB (api11) so keep that in mind when developing for older Android versions.

Also it is stated that your EditText should not be the first view to receive focus when activity starts (if it is - just requestFocus() from another view). Though I (personally) have not experienced any problems with this.

like image 173
Alex Semeniuk Avatar answered Sep 22 '22 11:09

Alex Semeniuk