Androidソフトキーボードはイジェクトできません
2980 ワード
ソフトキーボードが呼び出せない問題を1回記録します
一、前提条件
Activity、AndroidManifestを設定します.xml属性android:windowSoftInputMode="stateVisible|adjustResize"EditText自分をクリックすると、システムルールによりソフトキーボードが呼び出されます
二、操作表現
EditTextをクリックして、システムはソフトキーボードを呼び出していないで、なぜか原因が分かりませんか?だから手動でソフトキーボードを呼び出して呼び出すことができるかどうかを見ます
まだソフトキーボードを呼び出すことができないことが判明したため、Debug showSoftInputのソースコード
三、追跡問題
1、Debug showSoftInputソースコードのみ、最終的に
届いたviewがEditViewであることに気づき、何の問題もなく、問題はmSerbedView!=viewはtrueとして返され、mServiceViewは意外にも別のviewであるため、mServicesを下に呼び出すことはできない.showSoftInput(mClient,flags,resultReceiver)ソフトキーボードを有効にする
2、mSerbedViewの割り当て位置を探して、
最終的にActivityでEditViewの焦点が失われ、mSerbedViewが再割り当てされ、mSerbedView=mNextSerbedViewとなります.だから...
一、前提条件
Activity、AndroidManifestを設定します.xml属性android:windowSoftInputMode="stateVisible|adjustResize"EditText自分をクリックすると、システムルールによりソフトキーボードが呼び出されます
二、操作表現
EditTextをクリックして、システムはソフトキーボードを呼び出していないで、なぜか原因が分かりませんか?だから手動でソフトキーボードを呼び出して呼び出すことができるかどうかを見ます
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.showSoftInput(mContentEditText, InputMethodManager.SHOW_FORCED);
まだソフトキーボードを呼び出すことができないことが判明したため、Debug showSoftInputのソースコード
三、追跡問題
1、Debug showSoftInputソースコードのみ、最終的に
public boolean showSoftInput(View view, int flags, ResultReceiver resultReceiver) {
checkFocus();
synchronized (mH) {
if (mServedView != view && (mServedView == null
|| !mServedView.checkInputConnectionProxy(view))) {
return false;
}
try {
return mService.showSoftInput(mClient, flags, resultReceiver);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
}
届いたviewがEditViewであることに気づき、何の問題もなく、問題はmSerbedView!=viewはtrueとして返され、mServiceViewは意外にも別のviewであるため、mServicesを下に呼び出すことはできない.showSoftInput(mClient,flags,resultReceiver)ソフトキーボードを有効にする
2、mSerbedViewの割り当て位置を探して、
private boolean checkFocusNoStartInput(boolean forceNewFocus) {
// This is called a lot, so short-circuit before locking.
if (mServedView == mNextServedView && !forceNewFocus) {
return false;
}
final ControlledInputConnectionWrapper ic;
synchronized (mH) {
if (mServedView == mNextServedView && !forceNewFocus) {
return false;
}
if (DEBUG) Log.v(TAG, "checkFocus: view=" + mServedView
+ " next=" + mNextServedView
+ " forceNewFocus=" + forceNewFocus
+ " package="
+ (mServedView != null ? mServedView.getContext().getPackageName() : ""));
if (mNextServedView == null) {
finishInputLocked();
// In this case, we used to have a focused view on the window,
// but no longer do. We should make sure the input method is
// no longer shown, since it serves no purpose.
closeCurrentInput();
return false;
}
ic = mServedInputConnectionWrapper;
mServedView = mNextServedView;
mCurrentTextBoxAttribute = null;
mCompletions = null;
mServedConnecting = true;
}
if (ic != null) {
ic.finishComposingText();
}
return true;
}
最終的にActivityでEditViewの焦点が失われ、mSerbedViewが再割り当てされ、mSerbedView=mNextSerbedViewとなります.だから...