gpt4 book ai didi

android - InputMethodService onCreateInputView 从未调用过

转载 作者:行者123 更新时间:2023-11-29 21:28:23 25 4
gpt4 key购买 nike

我有一个非常简单的 InputMethodService,我所做的就是记录生命周期的不同阶段。我的 onCreateInputView 从未被调用,并且日志显示奇怪的事情。

  MyInput       D  onCreate
D onInitializeInterface
D onBindInput
D onStartInput
D onUnbindInput
D onBindInput
D onStartInput
D onUnbindInput
D onBindInput
D onStartInput
D onShowInputRequested

我只在 onShowInputRequested 被调用时点击了文本输入。当在屏幕之间导航时,它会在 onBindonStartInputonUnbind 之间循环。我错过了什么吗?

public class MyInput extends InputMethodService {
private static final String TAG = "MyInput";

private InputMethodManager mInputMethodManager;

@Override
public void onCreate() {
super.onCreate();
mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
Log.d(TAG, "onCreate");
}

@Override
public void onInitializeInterface() {
super.onInitializeInterface();
Log.d(TAG, "onInitializeInterface");
}

@Override
public View onCreateInputView() {
Log.d(TAG, "onCreateInputView");
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return inflater.inflate(R.layout.my_keyboard, null);
}

@Override
public void onFinishInput() {
super.onFinishInput();
Log.d(TAG, "onFinishInput");
}

@Override
public void onStartInput(EditorInfo attribute, boolean restarting) {
super.onStartInput(attribute, restarting);
Log.d(TAG, "onStartInput");
}

@Override
public void onFinishInputView(boolean finishingInput) {
super.onFinishInputView(finishingInput);
Log.d(TAG, "onFinishInputView");
}

@Override
public boolean onShowInputRequested(int flags, boolean configChange) {
Log.d(TAG, "onShowInputRequested");
return super.onShowInputRequested(flags, configChange);
}

@Override
public void onBindInput() {
super.onBindInput();
Log.d(TAG, "onBindInput");
}

@Override
public void onUnbindInput() {
super.onUnbindInput();
Log.d(TAG, "onUnbindInput");
}

@Override
public void onStartInputView(EditorInfo attribute, boolean restarting) {
super.onStartInputView(attribute, restarting);
Log.d(TAG, "onStartInputView restarting = " + restarting);
}

@Override
public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype) {
Log.d(TAG, "onCurrentInputMethodSubtypeChanged");
}
}

最佳答案

我已经删除了所有重写的方法,只留下了 onCreateInputView 并且现在调用了它,不知道是什么不起作用,特别是因为我到处都在调用父类(super class)方法...

关于android - InputMethodService onCreateInputView 从未调用过,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19957973/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com