Class Structure:
Note: EditText is a type of control that can be edited and input. It can be seen from the class structure diagram that it is a subclass of TextView. Therefore, it has some attributes of TextView. Below is an example of EditText.
Practical drills:
1. How to set a maximum of N characters
Set by: android: maxLength
<EditText
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: hint = "prompt text"
Android: maxLength = "4"
/>
Effect: only four words can be entered.
2. How do I set that only numbers can be entered?
Android: numeric has the following values: integer signed decimal.
<EditText android: id = "@ + id/myETxt02" android: layout_width = "fill_parent"
Android: layout_height = "wrap_content" android: numeric = "integer"/>
3. How do I set the password to the input format?
By setting android: password = "true", you can
<EditText android: id = "@ + id/myETxt02" android: layout_width = "fill_parent"
Android: layout_height = "wrap_content" android: password = "true"/>
Effect:
4. How to set the status to uneditable?
Method 1: android: editable = "false"
<EditText android: id = "@ + id/myETxt04" android: layout_width = "fill_parent"
Android: layout_height = "wrap_content" android: editable = "false"
Android: text = "editable"/>
Method 2:
MyEditText05 = (EditText) findViewById (R. id. myETxt05 );
// Set to uneditable
MyEditText05.setEnabled (false );
This is equivalent to the TextView control.
From: jiahui524 Column