• SoftKeyboard详解


    1. public void onCreate()

    Main initialization of the input method component. Be sure to call to super class.

    Overrides: onCreate() in InputMethodService

    2. public void onInitializeInterface()

    This is the point where you can do all of your UI initialization. It is called after creation and any configuration change.

    Overrides: onInitializeInterface() in InputMethodService

    3. public View onCreateInputView()

    Called by the framework when your view for creating input needs to be generated. This will be called the first time your input method is displayed, and every time it needs to be re-created such as due to a configuration change.

    Overrides: onCreateInputView() in InputMethodService

    4. public View onCreateCandidatesView()

    Called by the framework when your view for showing candidates needs to be generated, like onCreateInputView.

    Overrides: onCreateCandidatesView() in InputMethodService

    5. public void onStartInput(EditorInfo attribute, boolean restarting)

    This is the main point where we do our initialization of the input method to begin operating on an application. At this point we have been bound to the client, and are now receiving all of the detailed information about the target of our edits.

    Overrides: onStartInput(...) in InputMethodService

    Parameters:

    • attribute The attributes of the editor that input is starting in.
    • restarting Set to true if input is restarting in the same editor such as because the application has changed the text in the editor. Otherwise will be false, indicating this is a new session with the editor.

    6. public void onFinishInput()

    This is called when the user is done editing a field. We can use this to reset our state.

    Overrides: onFinishInput() in InputMethodService

    7. public void onStartInputView(EditorInfo attribute, boolean restarting)

    Called when the input view is being shown and input has started on a new editor. This will always be called after onStartInput, allowing you to do your general setup there and just view-specific setup here. You are guaranteed that onCreateInputView() will have been called some time before this function is called.

    Overrides: onStartInputView(...) in InputMethodService

    Parameters:

    • attribute Description of the type of text being edited.
    • restarting Set to true if we are restarting input on the same text field as before.

    8. public void onUpdateSelection(int oldSelStart, int oldSelEnd, int newSelStart, int newSelEnd, int candidatesStart, int candidatesEnd)

    Deal with the editor reporting movement of its cursor.

    Overrides: onUpdateSelection(...) in InputMethodService

    9. public void onDisplayCompletions(CompletionInfo[] completions)

    This tells us about completions that the editor has determined based on the current text in it. We want to use this in fullscreen mode to show the completions ourself, since the editor can not be seen in that situation.

    Overrides: onDisplayCompletions(...) in InputMethodService

    10. private boolean translateKeyDown(int keyCode, KeyEvent event)

    This translates incoming hard key events into edit operations on an InputConnection. It is only needed when using the PROCESS_HARD_KEYS option.

    11. public boolean onKeyDown(int keyCode, KeyEvent event)

    Use this to monitor key events being delivered to the application. We get first crack at them, and can either resume them or let them continue to the app.

    Overrides: onKeyDown(...) in InputMethodService

    Parameters:

    • keyCode The value in event.getKeyCode().
    • event Description of the key event.

    Returns:

    • If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

    12. public boolean onKeyUp(int keyCode, KeyEvent event)

    Use this to monitor key events being delivered to the application. We get first crack at them, and can either resume them or let them continue to the app.

    Overrides: onKeyUp(...) in InputMethodService

    Parameters:

    • keyCode The value in event.getKeyCode().
    • event Description of the key event.

    Returns:

    • If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

    13. private void commitTyped(InputConnection inputConnection)

    Helper function to commit any text being composed into the editor.

    14. private void updateShiftKeyState(EditorInfo attr)

    Helper to update the shift state of our keyboard based on the initial editor state.

    15. private boolean isAlphabet(int code)

    Helper to determine if a given character code is alphabetic(字母的、照字母次序的).

    16. private void keyDownUp(int keyEventCode)

    Helper to send a key down / key up pair to the current editor.

    17. private void sendKey(int keyCode)

    Helper to send a character to the editor as raw key events.

    18. public void onKey(int primaryCode, int[] keyCodes)

    Send a key press to the listener.

    Specified by: onKey(...) in OnKeyboardActionListener

    Parameters:

    • primaryCode this is the key that was pressed
    • keyCodes the codes for all the possible alternative keys with the primary code being the first. If the primary key code is a single character such as an alphabet or number or symbol, the alternatives will include other characters that may be on the same key or adjacent keys. These codes are useful to correct for accidental presses of a key adjacent to the intended key.

    19. public void onText(CharSequence text)

    Sends a sequence of characters to the listener.

    Specified by: onText(...) in OnKeyboardActionListener

    Parameters:

    • text the sequence of characters to be displayed.

    20. private void updateCandidates()

    Update the list of available candidates from the current composing text. This will need to be filled in by however you are determining candidates.

    21. public void setSuggestions(List<String> suggestions, boolean completions, boolean typedWordValid)

    22. private void handleBackspace()

    23. private void handleShift()

    24. private void handleCharacter(int primaryCode, int[] keyCodes)

    25. private void handleClose()

    26. private void checkToggleCapsLock()

    27. private String getWordSeparators()

    28. public boolean isWordSeparator(int code)

    29. public void pickDefaultCandidate()

    30. public void pickSuggestionManually(int index)

  • 相关阅读:
    [SDOI2012]任务安排
    JavaScript数据存储和深浅拷贝实际运用
    在VUE中使用Echarts
    JavaScript的原型链
    关于JavaScript的43道题①
    JS为什么是单线程的?
    HTTP协议②缓存
    HTTP协议①介绍
    树形结构的数据渲染(element-ui&VUE)
    js中定义变量之②var let const的区别
  • 原文地址:https://www.cnblogs.com/fengzhblog/p/2787959.html
Copyright © 2020-2023  润新知