public abstract class

TextEdit

extends View
java.lang.Object
   ↳ com.neomades.ui.View
     ↳ com.neomades.ui.TextEdit
Known Direct Subclasses
Known Indirect Subclasses

Summary

XML Attributes
Attribute Name Related Method Description
autoCorrect setAutoCorrect(boolean) Auto-correct mode  
capitalizeMode setCapitalizeMode(CapitalizeMode) Capitalize mode  
contentAlignment setContentAlignment(int) A combination of alignment values (eg: TOP|LEFT)  
cursorPosition setCursorPosition(int) The caret position  
defaultText setDefaultText(int) Res.string.XXXX or a text  
font setFont(Font) Font resource id: Res.font.FONT_XXXX  
maxLength setMaxLength(int) Max number of characters  
passwordMode setPasswordMode(boolean) If the field hides characters  
readOnly setReadOnly(boolean) If the text inside is not editable  
text setText(int) Res.string.XXXX or a text  
textColor setTextColor(Color) #AARRGGBB or a color  
textMode setTextMode(TextMode) The text mode  
textSize setTextSize(int) a size in dp  
[Expand]
Inherited XML Attributes
From class com.neomades.ui.View
[Expand]
Inherited Constants
From interface com.neomades.ui.Alignment
From interface com.neomades.ui.StretchMode
Public Constructors
TextEdit()
Public Methods
void clear()
Removes the text of this field
String getDefaultText()
Gets the default text of this text field.
String getText()
Returns the text of this text field.
boolean isReadOnly()
Returns if the the field is readonly or can be edited
int length()
Returns the length of the text of this field
void setAutoCorrect(boolean autocorrect)
Sets if auto-correct should be enabled.
void setCapitalizeMode(CapitalizeMode mode)
Changes the capitalize mode.
void setContentAlignment(int alignment)
Sets the alignment of the text in this component.
void setCursorPosition(int index)
Moves the cursor position before the character at the given index.
void setDefaultText(String defaultText)
Sets the default text of this text field, it disappears when the first character is entered and reappears when all characters have been deleted.
void setDefaultText(int resId)
Sets the default text of this text field, it disappears when the first character is entered and reappears when all characters have been deleted.
void setFont(Font font)
Sets the font for this text field
void setMaxLength(int maxLength)
Sets the maximum number of authorized characters into this TextField.
void setPasswordMode(boolean passwordMode)
Sets the password mode.
void setReadOnly(boolean readonly)
Sets the state of this field to readonly or editable
void setReturnKeyListener(ReturnKeyListener returnKeyListener)
Associates a ReturnKeyListener to this TextField.
void setReturnKeyType(int returnKeyType)
Changes the content of the return key.
void setText(String text)
Sets the text of this text field
void setText(int resId)
Sets the text of the text field
void setTextChangedListener(TextChangedListener listener)
Sets a text change listener (called when the text has been changed by the user)
void setTextColor(Color color)
Sets the text color of this textfield's text
void setTextMode(TextMode mode)
Changes the text mode.
void setTextSize(int sizeInDp)
Sets the text size to a given value (in dp).
[Expand]
Inherited Methods
From class com.neomades.ui.View
From class java.lang.Object

XML Attributes

autoCorrect

Auto-correct mode

Related Methods

capitalizeMode

Capitalize mode

contentAlignment

A combination of alignment values (eg: TOP|LEFT)

Related Methods

cursorPosition

The caret position

Related Methods

defaultText

Res.string.XXXX or a text

Related Methods

font

Font resource id: Res.font.FONT_XXXX

Related Methods

maxLength

Max number of characters

Related Methods

passwordMode

If the field hides characters

Related Methods

readOnly

If the text inside is not editable

Related Methods

text

Res.string.XXXX or a text

Related Methods

textColor

#AARRGGBB or a color

Related Methods

textMode

The text mode

Related Methods

textSize

a size in dp

Related Methods

Public Constructors

public TextEdit ()

Public Methods

public void clear ()

Removes the text of this field

Throws
CrossThreadException if the method is called from outside the UI-Thread

public String getDefaultText ()

Gets the default text of this text field. Returns an empty string ("") if there is no text.

Related XML Attributes
Returns
  • the default text. Returns an empty string ("") if there is no text.

public String getText ()

Returns the text of this text field. Returns an empty string ("") if there is no text.

Returns
  • the current text. Returns an empty string ("") if there is no text.

public boolean isReadOnly ()

Returns if the the field is readonly or can be edited

Returns
  • true if the field is readonly, else false

public int length ()

Returns the length of the text of this field

Returns
  • the length of the current text

public void setAutoCorrect (boolean autocorrect)

Sets if auto-correct should be enabled. If enabled, text may be corrected automatically while the user is typing.
By default, the auto-correct option is activated.
With auto-correct mode often comes a suggestions list, that is displayed above the keyboard.
When the keyboard is opened, changing the auto-correct mode may not take effect immediately, but only after the keyboard is re-opened.

Cross Platform Considerations

Has effect only on Android and iOS. On some platforms, like Android, this option exists as a global setting at system level, and can be toggled by the user. In this case, this setter may have no effect.

Related XML Attributes
Parameters
autocorrect true to activate auto-correct, else false

public void setCapitalizeMode (CapitalizeMode mode)

Changes the capitalize mode. See CapitalizeMode for a list of possible values.
The capitalize mode does not enforce users to use the specified case, it is just a hint. The user can still change the mode explicitly on the keyboard.

Related XML Attributes
Parameters
mode the capitalize mode to apply to this text edit
Throws
NullPointerException if the parameter is null

public void setContentAlignment (int alignment)

Sets the alignment of the text in this component. The alignment will be used only if the text is smaller than the TextField size. (default : VCENTER|LEFT)

In MATCH_CONTENT mode, the TextField size is the same than the text size, then this alignment property will be inefficient.

The parameter is a combination of values from Alignment.

Related XML Attributes
Parameters
alignment The new alignment of the text
Throws
CrossThreadException if the method is called from outside the UI-Thread

public void setCursorPosition (int index)

Moves the cursor position before the character at the given index. The field must have the focus: if the cursor is not already displayed, this method will have no effect.

Related XML Attributes
Parameters
index the new index
Throws
CrossThreadException if the method is called from outside the UI-Thread
IndexOutOfBoundsException if index is negative or larger than the text length

public void setDefaultText (String defaultText)

Sets the default text of this text field, it disappears when the first character is entered and reappears when all characters have been deleted.

Related XML Attributes
Parameters
defaultText the new default text
Throws
CrossThreadException if the method is called from outside the UI-Thread

public void setDefaultText (int resId)

Sets the default text of this text field, it disappears when the first character is entered and reappears when all characters have been deleted.

Related XML Attributes
Parameters
resId the string id representing the default text of this field
Throws
CrossThreadException if the method is called from outside the UI-Thread

public void setFont (Font font)

Sets the font for this text field

Related XML Attributes
Parameters
font the new font to set
Throws
CrossThreadException if the method is called from outside the UI-Thread
NullPointerException if the font parameter is null

public void setMaxLength (int maxLength)

Sets the maximum number of authorized characters into this TextField.

Related XML Attributes
Parameters
maxLength a positive value for a limited number of characters or -1 for no limit.

public void setPasswordMode (boolean passwordMode)

Sets the password mode.

Cross Platform Considerations

  • In iOS the password mode has no visible effect for TextArea.

Related XML Attributes
Parameters
passwordMode true to set password edition
Throws
CrossThreadException if the method is called from outside the UI-Thread

public void setReadOnly (boolean readonly)

Sets the state of this field to readonly or editable

Related XML Attributes
Parameters
readonly true if the textfield could not be edited by the user
Throws
CrossThreadException if the method is called from outside the UI-Thread

public void setReturnKeyListener (ReturnKeyListener returnKeyListener)

Associates a ReturnKeyListener to this TextField. Required to customize the behavior of the application when the user presses the "Return" key of the keyboard that was opened for this TextField.

Parameters
returnKeyListener the callback used to listen press event on "Return" for the keyboard of the TextField

public void setReturnKeyType (int returnKeyType)

Changes the content of the return key. Depending on the platform it can be a text or in image. The default content is a "Done" button.

Limitations

  • In some Android device running a specific constructor layer, this method may have no effect (device running HTC Sense for example)

Parameters
returnKeyType the ReturnKeyType of the keyboard for this TextField

public void setText (String text)

Sets the text of this text field

Related XML Attributes
Parameters
text the new text
Throws
CrossThreadException if the method is called from outside the UI-Thread

public void setText (int resId)

Sets the text of the text field

Related XML Attributes
Parameters
resId the string id representing the text of this text field
Throws
CrossThreadException if the method is called from outside the UI-Thread

public void setTextChangedListener (TextChangedListener listener)

Sets a text change listener (called when the text has been changed by the user)

Parameters
listener the callback used to listen text changes

public void setTextColor (Color color)

Sets the text color of this textfield's text

Related XML Attributes
Parameters
color The color to set (with the alpha channel)
Throws
CrossThreadException if the method is called from outside the UI-Thread

public void setTextMode (TextMode mode)

Changes the text mode. See TextMode for a list of possible values.
The text mode does not enforce users to use the specified keyboard, it is just a hint. The user can still use characters that may differ from the specified text mode, for example alphabetic characters instead of digits.

Related XML Attributes
Parameters
mode the text mode to apply to this text edit
Throws
NullPointerException if the parameter is null

public void setTextSize (int sizeInDp)

Sets the text size to a given value (in dp).

Related XML Attributes
Parameters
sizeInDp size to set to the text