Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Learn about EditText little depth     - Why HBase need to build SQL engine layer (Database)

- The Gitlab migrated to Docker container (Server)

- stat Usage: Get permission to file the corresponding figures (Linux)

- CentOS 6.6 install JDK7 (Linux)

- According to the national position on how to block traffic in Linux (Server)

- Object-C in the preparation of multi-parameter function parameter is omitted (Programming)

- MySQL simple operation notes under Linux (Database)

- Oracle TDE transparent data encryption (Database)

- CentOS 6.4 (64bit) install Python 2.7.5 (Linux)

- Linux Fundamentals of the text, data flow processing orders (Linux)

- Java implementation heap sort (large root heap) (Programming)

- Error code: 2013 Lost connection to MySQL server during query (Database)

- Ubuntu uses under KVM + Qemu virtual machine build (Linux)

- Bash mathematical extension (Programming)

- A list of the basics of Python, Ganso, Dictionary (Programming)

- Oracle 11g RAC manually playing GI PSU patch ( (Database)

- Android to determine whether the device to open WIFI, GPRS data connection (Programming)

- To install Python-Pip and Fabric under CentOS / Ubuntu (Linux)

- MySQL 5.5 on master-slave copy filter (Database)

- Use web2py + uWSGI + Nginx Web server built on Linux (Server)

  Learn about EditText little depth
  Add Date : 2016-05-02      
  Recently in the development of Android under the Notepad program, frequent use EditText control, toss to toss, be more in-depth understanding of their number. These special record harvest will be as follows:

Introduced a few attributes

android: gravity = "top"

This attribute can place the cursor for the top left corner (when EditText set to full screen)

android: background = "@ null"

This property is null can remove the input border

android: textCursorDrawable = "@ drawable / ic_launcher"

This property can be set to drawable cursor style (for a picture)

android: editable = "false"

This property is false, then the EditText is not editable. Note that not only is input, but what is still rolling EditText can respond.

 android: enabled = "false"

This property is false, then the EditText is not editable. Note that not only can not be edited, what can not even roll response, it can be said directly EditText unavailable.

 android: cursorVisible = "false"

This property is false, then the EditText cursor invisible.

android: focusableInTouchMode = "false"

This property is false, then the EditText does not respond to touch focus mode, or touch event is unavailable.

Second, the input monitor EditText

    It can be used to monitor EditText TextWatcher input. Use as follows:

Et.addTextChangedListener (new TextWatcher () {
             // S: all the characters after the change; start: The starting position of the character; before: total number of bytes before the change; count: the number of bytes after the change
            public void onTextChanged (CharSequence s, int start, int before, int count) {

 // S: all the characters before the change; start: Start position of character; count: The total number of bytes before the change; after: the number of bytes after the change
            public void beforeTextChanged (CharSequence s, int start, int count,
                    int after) {
// S: all the characters after the change
            public void afterTextChanged (Editable s) {
So if there is a need, or to do some EditText personalized settings that you can use to add a listener for addTextChangedListener EditText!
Third, make read-only EditText controls

      First, explain Demand: The EditText only prohibit the importation, but you can view, scroll, and will respond to touch anything that is merely prohibit the importation of it! Call it read-only mode.

     How to produce a EditText it like this? Online there are many ways, I almost tried one by one, but the methods used are unable to achieve satisfaction. such as:

(1) If by setting android: editable attribute to make EditText can not enter. Although this can perfectly meet the requirements. However, when the need to restore the EditText and enter the state, there is no corresponding dynamic code to recover!

(2) If you use the android: enabled attribute, then make EditText entire unavailable, meaning that not only can not enter, do not even what the scroll.

     Finally, Lile ideas, and finally solve the problem. Up to my expectations: the EditText read-only mode to achieve, and when restoring its editable state can be easily restored.

My approach is as follows:

Create a read-only mode EditText

In fact, very simple settings to carry out the following two steps:
(1) read-only mode, of course, do not need to display the cursor. You can set the following in xml:
 android: cursorVisible = "false"
(2) read-only mode, of course do not need to pop input method, input method does not pop up, of course, can not be edited. To point to the EditText let pop input method, we simply are not allowed to respond to touch events:
 android: focusableInTouchMode = "false"

After the above two-step simple setup, you can make a EditText read-only mode.

Then restore EditText editable:

According to the above settings, so you want to restore the EditText editable, only the following two lines of code:
editText.setFocusableInTouchMode (true);
editText.setCursorVisible (true);
   Also need to note is that you can also use the following method may be dynamically set EditText input and non-input state.

   Dynamically set EditText can not enter any character

// Set the EditText can not enter. But keep sliding, tap and other attributes. But it can not be entered
        et.setFilters (new InputFilter [] {new InputFilter () {
            public CharSequence filter (CharSequence source, int start,
                    int end, Spanned dest, int dstart, int dend) {
                return source.length () <1 dest.subSequence (dstart, dend): "";?
Thus, with the above code, even if you are using the input keyboard input, but also can not enter into the EditText. Corresponding to the respective input can be used to restore the following code:

// Set the input method to enter (or called recovery input)
            et.setFilters (new InputFilter [] {new InputFilter () {
                public CharSequence filter (CharSequence source, int start,
                        int end, Spanned dest, int dstart, int dend) {
                    // TODO Auto-generated method stub
                    return null;

Fourth, do not automatically pop up keyboard input methods
      When your layout contains a EditText in, you'll find that if you enter the event interface, keyboard input method will automatically pop up. First, you do not intend to make EditText input time,

This automatic pop-up input rule is very irritating! So you can use the following two ways to disable the automatic pop-up because EditText input method:

(1) a method
   After the test, and if the EditText TextView together, then the input method does not pop up automatically. This is due to the very nature TextView result. Incidentally, EditText itself is inherited from the TextView.
   So you can put a TextView to your layout to prevent the automatic pop input method.

(2) Method II
   You can also use the code to dynamically set the input method does not pop up. Just in the right place, and wrote the following code. The following code is to make the EditText default does not display the soft keyboard, only when is clicked will show the soft keyboard
getWindow () setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE. |
  Fifth, set a password EditText display format

     There are two ways that exploit code in xnl and dynamic setting. as follows:

(1) a way
android: inputType = "textPassword"
(2) Second way
edit.setTransformationMethod (PasswordTransformationMethod.getInstance ());
   inputType is the type of input characters. Here there is a good online summary, as follows:

 1 android: inputType Parameter Type Description
 2 android: inputType = "none" - ordinary character input
 3 android: inputType = "text" - ordinary character input
 4 android: inputType = "textCapCharacters" - ordinary character input
 5 android: inputType = "textCapWords" - the first letter of the word size
 6 android: inputType = "textCapSentences" - only the first letter size
 7 android: inputType = "textAutoCorrect" - the first two AutoComplete
 8 android: inputType = "textAutoComplete" - the first two AutoComplete
 9 android: inputType = "textMultiLine" - multi-line input
10 android: inputType = "textImeMultiLine" - input multiple lines (not necessarily support)
11 android: inputType = "textNoSuggestions" - Do not prompt
12 android: inputType = "textUri" - URI format
13 android: inputType = "textEmailAddress" - email address format
14 android: inputType = "textEmailSubject" - the theme of the message format
15 android: inputType = "textShortMessage" - short message format
16 android: inputType = "textLongMessage" - a long message format
17 android: inputType = "textPersonName" - Names Format
18 android: inputType = "textPostalAddress" - Post format
19 android: inputType = "textPassword" - password format
20 android: inputType = "textVisiblePassword" - password visible format
21 android: inputType = "textWebEditText" - as a web form text format
22 android: inputType = "textFilter" - text filter format
23 android: inputType = "textPhonetic" - Pinyin input format
24 android: inputType = "number" - number format
25 android: inputType = "numberSigned" - signed digital format
26 android: inputType = "numberDecimal" - floating point format with a decimal point
27 android: inputType = "phone" - Dialpad
28 android: inputType = "datetime"
29 android: inputType = "date" - the date of the keyboard
30 android: inputType = "time" - time keyboard
Here then plug a bar. Talk about EditText or TextView in setInputType and setTransformationmethod methods.
(1) setinputType can set the EditText (TextView to be) input mode. For example, Contact, Email, Date, Time, Short Message, Normal Text, Password and so on.

You can also specify a variety of correction options, such as the first word in capital letters, the first letter of a sentence uppercase, AutoCorrect and so on. The following code is an example of use:

 int inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
                      | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
                      | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
      EditText.setInputType (inputType);
(2) setTransformationMethod can support the input character conversion, including the removal of line breaks, converted mask. Instructions:

 textView.setTransformationMethod (PasswordTransformationMethod.getInstance ());
In summary, if you need to implement your own conversion, you can achieve TransformationMethod interfaces to achieve your goal (such as all the characters are entered into a, or enter a display z, z enter a display, etc.).
- Ubuntu uses conky add desktop control (Linux)
- C # using the HttpClient Note: Preheat the long connection (Programming)
- Prevent security threats caused Rootkit (Linux)
- Java-based data source database access (Programming)
- Ubuntu 14.04 install Sublime Text 3 plug and use SublimeClang (Linux)
- ThinkPad X201i installation notes Debian 7.5 (Linux)
- Share and show your code on GitHub (Linux)
- Linux static library generated Guide (Programming)
- VirtualBox snapshots (Linux)
- CentOS 7 repair MBR and GRUB (Linux)
- High-performance JavaScript reflows and repaints (Programming)
- How to ensure the Linux SSH login security with one-time password (Linux)
- Use source packages compiled and installed GCC5.1 in Mac OS X 10.10.3 (Linux)
- Linux remote wake the computer original code [C] (Linux)
- Let Mac OS X dedicated high-speed mobile hard disk can also be read in Linux (Linux)
- Linux /var/spool/ insufficient clientmqueue space solutions (Linux)
- C ++ string in the end (Programming)
- Qt signals and slots mechanism (Programming)
- Binary search -Java achieve (Programming)
- VirtualBox install Windows 8.1 has encountered an error 0x000000C4 solutions (Linux)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.