我不确定如何从另一个类调用此方法,deleteSurroundingText(int leftLength, int rightLength)
它位于库中的 Class EmulatorView 中。但它似乎也嵌套在其他一些类中,所以我不能说类似EmulatorView.deleteSurroundingText(1,1);
这是关于该方法的内容:
boolean jackpal.androidterm.emulatorview.EmulatorView.onCreateInputConnection(...).new BaseInputConnection() {...}.deleteSurroundingText(int leftLength, int rightLength)
boolean jackpal.androidterm.emulatorview.EmulatorView.onCreateInputConnection(...).new BaseInputConnection() {...}.deleteSurroundingText(int leftLength, int rightLength)
Overrides: deleteSurroundingText(...) in BaseInputConnection
public boolean deleteSurroundingText (int beforeLength, int afterLength)
Added in API level 3
The default implementation performs the deletion around the current selection position of the editable text.
Parameters
beforeLength The number of characters to be deleted before the current cursor position.
afterLength The number of characters to be deleted after the current cursor position.
代码部分:
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
outAttrs.inputType = mUseCookedIme ?
EditorInfo.TYPE_CLASS_TEXT :
EditorInfo.TYPE_NULL;
return new BaseInputConnection(this, true) {
public boolean deleteSurroundingText(int leftLength, int rightLength) {
Log.w(TAG2, "in DeleteSurroundingText");
if (LOG_IME) {
Log.w(TAG, "deleteSurroundingText(" + leftLength +
"," + rightLength + ")");
}
if (leftLength > 0) {
for (int i = 0; i < leftLength; i++) {
sendKeyEvent(
new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
}
} else if ((leftLength == 0) && (rightLength == 0)) {
// Delete key held down / repeating
sendKeyEvent(
new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
}
// TODO: handle forward deletes.
//int i = 1;
//deleteSurroundingText(i, i);
return true;
}
};
}
谢谢