Thursday, February 5, 2015

Cocos2D-X: Disable Keyboard Autocomplete for Android

As at Cocos2D-X 3.2, it is not possible to disable autocomplete in the keyboard and this can prove to be a critical issue e.g. when user is keying in password.

A simple solution (which will disable autocomplete throughout the app) is to edit the "org.cocos2dx.lib.Cocos2dxActivity" file in the Cocos2D-X Android Java library. In the "init()" method, add the following line:

edittext.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | TYPE_TEXT_VARIATION_PASSWORD);

According to this article, some devices may require different flags: http://stackoverflow.com/questions/6281514/android-programmatically-disable-autocomplete-autosuggest-for-edittext-in-emulat

No comments:

Post a Comment