android - EditText typing is slow

后端 未结 5 2151
囚心锁ツ
囚心锁ツ 2021-02-09 22:05

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

相关标签:
5条回答
  • 2021-02-09 22:29

    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.

    0 讨论(0)
  • 2021-02-09 22:37

    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...

    0 讨论(0)
  • 2021-02-09 22:44
    android:vmSafeMode="true"
    

    removing this attribute from manifest it will work. its working for me.

    0 讨论(0)
  • 2021-02-09 22:49

    I found that switching off the predictive text helped.

    android:inputType="text|textNoSuggestions"
    
    0 讨论(0)
  • 2021-02-09 22:50

    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.

    0 讨论(0)
提交回复
热议问题