I\'ve got an EditText that is SLOW to respond when typing. The lag is annoying enough to cause me to find a solution. I did some research and found an SO thread EditText laggi
I was having a similar issue using EditText
inside a ListView
, that was fixed by changing the EditText width
to 0dp
using weighted widths to match/fill the parent.
I don't know for sure why this was occurring, however I believe it is because when the width of the EditText
is set to wrap content it will adjust/redraw itself so that everything fits, and the ListView
will also attempt to redraw itself so everything fits. So by making the EditText
have a fixed width, this redraw is no longer required.
Edit AndroidManifest
:
My old code
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" />
My new code
<uses-sdk android:minSdkVersion="8" />
I just removed the targetSdkVersion
and the lag gone away...
android:vmSafeMode="true"
removing this attribute from manifest it will work. its working for me.
I found that switching off the predictive text helped.
android:inputType="text|textNoSuggestions"
When you typing text, the onTextChanged
is called again and again, so you are starting an new thread (EditTextWatcherTask
) again and again. It will consume many resource of the system.
As well thread is for the task that need many time to finish it, so in your situation, you don't need a thread, remove the task, just put the computation code in the onTextChanged
.