我想在我的数组中放入10个数字,但是我得到了未定义的
public class EDMTKeyboard extends InputMethodService implements KeyboardView.OnKeyboardActionListener {
private KeyboardView kv;
private Keyboard keyboard;
private boolean isCaps = false;
@Override
public View onCreateInputView() {
kv = (KeyboardView)getLayoutInflater().inflate(R.layout.keyboard,null);
keyboard = new Keyboard(this,R.xml.qwerty);
kv.setKeyboard(keyboard);
kv.setOnKeyboardActionListener(this);
return kv;
}
@Override
public void onPress(int i) {
}
@Override
public void onRelease(int i) {
}
@Override
public void onKey(int i, int[] ints) {
InputConnection ic = getCurrentInputConnection();
playClick(i);
switch (i)
{
case Keyboard.KEYCODE_DELETE:
ic.deleteSurroundingText(1,0);
break;
case Keyboard.KEYCODE_SHIFT:
isCaps = !isCaps;
keyboard.setShifted(isCaps);
kv.invalidateAllKeys();
break;
case Keyboard.KEYCODE_DONE:
//ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_ENTER));
break;
default:
char code = (char)i;
if(Character.isLetter(code) && isCaps)
code = Character.toUpperCase(code);
ic.commitText(String.valueOf(code),1);
}
}
private void playClick(int i) {
AudioManager am = (AudioManager)getSystemService(AUDIO_SERVICE);
switch(i)
{
case 32:
am.playSoundEffect(AudioManager.FX_KEYPRESS_SPACEBAR);
break;
case Keyboard.KEYCODE_DONE:
case 10:
am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);
break;
case Keyboard.KEYCODE_DELETE:
am.playSoundEffect(AudioManager.FX_KEYPRESS_DELETE);
break;
default: am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD);
}
}
@Override
public void onText(CharSequence charSequence) {
}
@Override
public void swipeLeft() {
}
@Override
public void swipeRight() {
}
@Override
public void swipeDown() {
}
@Override
public void swipeUp() {
}
我用(0)或(10)向arrayDrag声明,当我的事件是调用(rowDragEnd)时,我得到错误" undefined" public arrayDrag: number[];
ngOnInit() {
this.arrayDrag = new Array(); //or this.arrayDrag = new Array(10)
}
rowDragEnd(event) {
let max = 0;
this.arrayDrag = new Array(); //or this.arrayDrag = new Array(10)
this.gridApi.forEachNodeAfterFilterAndSort(function(node) {
if (max < 10) {
this.arrayDrag.push(node.data.point);
console.log('add', node.data.point);
max += 1;
}
});
}
答案 0 :(得分:6)
您需要使用箭头功能来维护组件的范围。
navigationController?.popViewController(animated: true)
dismiss(animated: true, completion: nil)
在您发布的代码中,您使用的是this.gridApi.forEachNodeAfterFilterAndSort((node) => {
if (max < 10) {
this.arrayDrag.push(node.data.point);
console.log('add', node.data.point);
max += 1;
}
});
,因此function
指的是功能,而不是您的组件。