titaniumappceleratorappcelerator-titaniumappcelerator-mobile

How to set a clear button in textfield for android in titanium?


I am trying to set a clear button in text field using clearbuttonmode where it is working fine with Ios Platform and is not showing up in android.


Solution

  • Since clearButtonMode (check your spelling) is only available for iOS as you can see in the documentation I would go the multiplatform way and create a own button and add it next to the TextField. The buttons just sets the TextField value to "" to clear the field. You could even put everything inside a <View> with a white background and a border so it will look like the clear Button is inside the TextField

    pseudo code:

    <View height="Ti.UI.SIZE" width="300">
      <TextField left="0" right="40"/>
      <Button width="40" right="0"/>
    </View>