本文整理了Java中android.inputmethodservice.Keyboard.getKeys()
方法的一些代码示例,展示了Keyboard.getKeys()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Keyboard.getKeys()
方法的具体详情如下:
包路径:android.inputmethodservice.Keyboard
类名称:Keyboard
方法名:getKeys
暂无
代码示例来源:origin: stackoverflow.com
case keycode:
Keyboard currentKeyboard = mInputView.getKeyboard();
List<Keyboard.Key> keys = currentKeyboard.getKeys();
mInputView.invalidateKey(*keycode*);
keys.get(*keycode*).label = null;
key.get(*keycode*).icon = getResources().getDrawable(R.drawable.image);
代码示例来源:origin: stackoverflow.com
Keyboard keyboard = keyboardView.getKeyboard();
List<Key> keys = keyboard.getKeys();
代码示例来源:origin: stackoverflow.com
@Override
public void onPress(int primaryCode)
{
Keyboard currentKeyboard = mInputView.getKeyboard();
List<Keyboard.Key> keys = currentKeyboard.getKeys();
mInputView.invalidateKey(primaryCode);
for(int i = 0; i < keys.size() - 1; i++ )
{
Keyboard.Key currentKey = keys.get(i);
//If your Key contains more than one code, then you will have to check if the codes array contains the primary code
if(currentKey.codes[0] == primaryCode)
{
currentKey.label = null;
currentKey.icon = getResources().getDrawable(android.R.drawable.ic_dialog_email);
break; // leave the loop once you find your match
}
}
}
代码示例来源:origin: PhilippC/keepass2android
public Key[] setKeyboard(Keyboard keyboard, float correctionX, float correctionY) {
if (keyboard == null)
throw new NullPointerException();
mCorrectionX = (int)correctionX;
mCorrectionY = (int)correctionY;
mKeyboard = keyboard;
List<Key> keys = mKeyboard.getKeys();
Key[] array = keys.toArray(new Key[keys.size()]);
mKeys = array;
return array;
}
代码示例来源:origin: zhuanghongji/custom-android-keyboard
private Keyboard.Key getKeyByKeyCode(int primaryCode) {
if(null != mKeyboard){
List<Key> keyList = mKeyboard.getKeys();
for (int i =0,size= keyList.size(); i < size; i++) {
Key key = keyList.get(i);
int codes[] = key.codes;
if(codes[0] == primaryCode){
return key;
}
}
}
return null;
}
代码示例来源:origin: zyl409214686/CustomKeyboardView
/**
* 根据key code 获取 Keyboard.Key 对象
* @param primaryCode
* @return
*/
private Keyboard.Key getKeyByKeyCode(int primaryCode) {
if(null != mKeyboard){
List<Keyboard.Key> keyList = mKeyboard.getKeys();
for (int i =0,size= keyList.size(); i < size; i++) {
Keyboard.Key key = keyList.get(i);
int codes[] = key.codes;
if(codes[0] == primaryCode){
return key;
}
}
}
return null;
}
代码示例来源:origin: PhilippC/keepass2android
private void findKeys() {
List<Key> keys = getKeyboard().getKeys();
// Get the keys on this keyboard
for (int i = 0; i < keys.size(); i++) {
int code = keys.get(i).codes[0];
if (code >= 0 && code <= 255) {
mAsciiKeys[code] = keys.get(i);
}
}
}
代码示例来源:origin: stackoverflow.com
Keyboard.Key key = findKey(myKeyboard, keyCode);
key.icon = myDrawable;
private Keyboard.Key findKey(Keyboard keyboard, int primaryCode) {
for (Keyboard.Key key : keyboard.getKeys()) {
if (key.codes[0] == primaryCode) {
return key;
}
}
return null;
}
代码示例来源:origin: conghuahuadan/CustomKeyboard
protected Keyboard.Key getKey(int code) {
List<Keyboard.Key> keyList = getKeyboard().getKeys();
for (Keyboard.Key key : keyList) {
if (key.codes[0] == code) {
return key;
}
}
return null;
}
代码示例来源:origin: onlyloveyd/LazyKeyboard
/**
* 键盘数字随机切换
*/
private void randomNumbers() {
List<Key> keylist = mKeyboardNumber.getKeys();
ArrayList<String> temNum = new ArrayList<>(nums_);
for (Key key : keylist) {
if (key.label != null && isNumber(key.label.toString())) {
int number = new Random().nextInt(temNum.size());
String[] text = temNum.get(number).split("#");
key.label = text[1];
key.codes[0] = Integer.valueOf(text[0], 10);
temNum.remove(number);
}
}
}
代码示例来源:origin: GitPhoenix/KeyboardView
/**
* 英文键盘大小写切换
*/
private void shiftEnglish() {
List<Keyboard.Key> keyList = keyboardEnglish.getKeys();
for (Keyboard.Key key : keyList) {
if (key.label != null && isKey(key.label.toString())) {
if (isCapital) {
key.label = key.label.toString().toLowerCase();
key.codes[0] = key.codes[0] + 32;
} else {
key.label = key.label.toString().toUpperCase();
key.codes[0] = key.codes[0] - 32;
}
}
}
isCapital = !isCapital;
}
代码示例来源:origin: wuzhendev/android-xnumberkeyboard
/**
* 打乱按键的顺序。
*/
private void shuffleKeys() {
Keyboard keyboard = getKeyboard();
if (keyboard != null && keyboard.getKeys() != null && keyboard.getKeys().size() > 0) {
// 随机排序数字
Collections.shuffle(keyCodes);
// 遍历所有的按键
List<Keyboard.Key> keys = getKeyboard().getKeys();
int index = 0;
for (Keyboard.Key key : keys) {
int code = key.codes[0];
// 如果按键是数字
if (code != KEYCODE_BOTTOM_LEFT && code != KEYCODE_BOTTOM_RIGHT) {
char keyCode = keyCodes.get(index++);
key.codes[0] = keyCode;
key.label = Character.toString(keyCode);
}
}
setKeyboard(keyboard);
}
}
代码示例来源:origin: zhuanghongji/custom-android-keyboard
private void changeKeyboart() {
List<Keyboard.Key> keyList = mLetterKeyboard.getKeys();
if (isUpper) { // 大写切换小写
isUpper = false;
for (Keyboard.Key key : keyList) {
if (key.label != null && isLetter(key.label.toString())) {
key.label = key.label.toString().toLowerCase();
key.codes[0] = key.codes[0] + 32;
}
}
} else { // 小写切换成大写
isUpper = true;
for (Keyboard.Key key : keyList) {
if (key.label != null && isLetter(key.label.toString())) {
key.label = key.label.toString().toUpperCase();
key.codes[0] = key.codes[0] - 32;
}
}
}
}
代码示例来源:origin: conghuahuadan/CustomKeyboard
private void toggleShift() {
Keyboard.Key key = getKey(Keyboard.KEYCODE_SHIFT);
int resId = isShift ?
R.drawable.ic_twotone_font_download_24dp : R.drawable.ic_outline_font_download_24dp;
key.icon = getResources().getDrawable(resId);
List<Keyboard.Key> keyList = getKeyboard().getKeys();
for (Keyboard.Key item : keyList) {
if (item.label != null && isWord(item.label.toString())) {
if (isShift) {
item.label = item.label.toString().toUpperCase();
} else {
item.label = item.label.toString().toLowerCase();
}
item.codes[0] = item.label.charAt(0);
}
}
}
代码示例来源:origin: wuzhendev/android-xnumberkeyboard
/**
* 配置左下角的特殊按键。
*/
private void settingSpecialKey() {
if (getKeyboard() == null || getKeyboard().getKeys() == null) {
return;
}
List<Keyboard.Key> keys = getKeyboard().getKeys();
for (Keyboard.Key key : keys) {
if (key.codes[0] == KEYCODE_BOTTOM_LEFT) {
key.label = mSpecialKey.keyLabel();
}
}
}
代码示例来源:origin: KDE/kdeconnect-android
void updateInputView() {
if (inputView == null)
return;
Keyboard currentKeyboard = inputView.getKeyboard();
List<Keyboard.Key> keys = currentKeyboard.getKeys();
boolean connected = RemoteKeyboardPlugin.isConnected();
// Log.d("RemoteKeyboardService", "Updating keyboard connection icon, connected=" + connected);
int disconnectedIcon = R.drawable.ic_phonelink_off_white_36dp;
int connectedIcon = R.drawable.ic_phonelink_white_36dp;
int statusKeyIdx = 3;
keys.get(statusKeyIdx).icon = getResources().getDrawable(connected ? connectedIcon : disconnectedIcon);
inputView.invalidateKey(statusKeyIdx);
}
代码示例来源:origin: conghuahuadan/CustomKeyboard
@Override
public void onDraw(Canvas canvas) {
handlerSpecKey();
super.onDraw(canvas);
for (Keyboard.Key item : getKeyboard().getKeys()) {
// drawNotTouchKey(item, canvas);
drawDoneKey(item, canvas);
}
}
代码示例来源:origin: PuffOpenSource/Puff-Android
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
List<Keyboard.Key> keys = getKeyboard().getKeys();
initType(keys);
for (Keyboard.Key key : keys) {
drawSpecialKey(key, canvas);
}
}
代码示例来源:origin: kuangch/custom-keyboard
/**
* 重新画一些按键
*/
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
mKeyBoard = this.getKeyboard();
List<Key> keys = null;
if (mKeyBoard != null) {
keys = mKeyBoard.getKeys();
}
if (keys != null) {
for (Key key : keys) {
// 数字键盘的处理
if (key.codes[0] == -4) {
drawKeyBackground(R.drawable.bg_keyboardview_yes, canvas, key);
drawText(canvas, key);
}
}
}
}
代码示例来源:origin: wuzhendev/android-xnumberkeyboard
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
// 重新绘制左下角和右下角的按键
List<Keyboard.Key> keys = getKeyboard().getKeys();
for (Keyboard.Key key : keys) {
// 如果是左下角按键
if (key.codes[0] == KEYCODE_BOTTOM_LEFT) {
drawKeyBackground(key, canvas, mSpecialKeyBackground);
drawSpecialKeyLabel(key, canvas);
}
// 如果是右下角按键
else if (key.codes[0] == KEYCODE_BOTTOM_RIGHT) {
drawKeyBackground(key, canvas, mBRKeyBackground);
drawBRKeyDrawable(key, canvas, mBRKeyDrawable);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!