I have an edittext in my application that will show the cursor correctly in Froyo or Gingerbread, however in later sdks the cursor is invisible. I have found online the solution is to set the android:textCursorDrawable="@null" so that the edittext will use the font color for the cursor. However, since my minsdkversion is 8, I do not have access to that property.
Is their either a way to selectively add a property based on the sdk you are on? Or possibly a way to work around this so that I can have visible cursors on both older and newer sdk versions?
Try setting your targetSdkVersion to API level 13 or higher to gain access to the android:textCursorDrawable property
If you not has a cursor I guess the input is simple and say you only can enter new chars at end of the text?
I think you can use a TextView and to this add you own KeyListener? But in this case you will has problem with the virtual keyboard not is show, see some of this links:
Forcing the Soft Keyboard open
android force keyboard visible
or create you own keyboard if the rang of valid keys is very limit as only digits.
I don't know your current setup, but one way to use that property is to use different layouts folders based on various android versions.
android:textCursorDrawable
is a property introduced in API 12 so you could have a layout folder likelayout-v12
which will be used where the API is 12 or greater. In the layouts from this folder the use of the property is valid. For lower versions,Froyo
andGingerbread
, you don't have any problems so you would use a default folder,layout
. In the end you'll have two layouts folder(containing the same layout files):That leaves out API 11, I don't know if this is a deal breaker for you.