【Android源码 栏目提醒】:以下是网学会员为您推荐的Android源码 -SoftKeyboard java android源码 - 开发文档,希望本篇文章对您学习有所帮助。
/ Copyright C 2008-2009 Google Inc. Licensed under the Apache License Version 2.0 the quotLicensequot you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing software distributed under the License is distributed on an quotAS ISquot BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied. See the License for the specific language governing permissions and limitations under the License. / package com.example.android.softkeyboard import android.inputmethodservice.InputMethodService import android.inputmethodservice.Keyboard import android.inputmethodservice.KeyboardView import android.text.method.MetaKeyKeyListener import android.util.Log import android.view.KeyCharacterMap import android.view.KeyEvent import android.view.View import android.view.inputmethod.CompletionInfo import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputConnection import android.view.inputmethod.InputMethodManager import java.util.ArrayList import java.util.List / Example of writing an input method for a soft keyboard. This code is focused on simplicity over completeness so it should in no way be considered to be a complete soft keyboard implementation. Its purpose is to provide a basic example for how you would get started writing an input method to be fleshed out as appropriate. / public class SoftKeyboard extends InputMethodService implements KeyboardView.OnKeyboardActionListener static final boolean DEBUG false / This boolean indicates the optional example code for performing processing of hard keys in addition to regular text generation from on-screen interaction. It would be used for input methods that perform language translations such as converting text entered on a QWERTY keyboard to Chinese but may not be used for input methods that are primarily intended to be used for on-screen text entry. / static final boolean PROCESS_HARD_KEYS true private KeyboardView mInputView private CandidateView mCandidateView private CompletionInfo mCompletions private StringBuilder mComposing new StringBuilder private boolean mPredictionOn private boolean mCompletionOn private int mLastDisplayWidth private boolean mCapsLock private long mLastShiftTime private long mMetaState private LatinKeyboard mSymbolsKeyboard private LatinKeyboard mSymbolsShiftedKeyboard private LatinKeyboard mQwertyKeyboard private LatinKeyboard mCurKeyboard private String mWordSeparators / Main initialization of the input method component. Be sure to call to super class. / Override public void onCreate super.onCreate mWordSeparators getResources.getStringR.string.word_separators / This is the point where you can do all of your UI initialization. It is called after creation and any configuration change. / Override public void onInitializeInterface if mQwertyKeyboard null // Configuration changes can happen after the keyboard gets recreated // so we need to be able to re-build the keyboards if the available // space has changed.