このメソッドを別のクラスから呼び出す方法がわかりません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;
}
};
}
ありがとう