Sunday, August 01, 2010

Issue on Android 1.5 TextView

When I implemented the drag-spacebar-to-change-language function in CedIME, It seems to work fine on my Nexus One. However testing it on HTC Magic with Android 1.5 reveals a problem - the spacebar drag image won't redraw itself when the spacebar is being dragged.

Since the code in CedIME for the two versions of Android are completely the same, it must be the problem within the Android framework code itself. After two days of tracing / debugging the issue, I found that the problem seems to resides in the TextView class's invalidateDrawable() method. In Android 2.2 this method is reimplemented differently and hence CedIME works fine on Nexus One.

The fix for this come as a sort of a hack. I have to resolve this using Java's reflection mechanism to access some private fields in the Android Framework. Not a very good solution as it may break on future Android versions. But, as long as it works...

No comments: