我的布局中有一个Fragment
(兼容版本) 。EditText
我正在使用 aViewFlipper
在片段之间翻转。当我到达这个特定Fragment
的,软键盘会自动打开。这不是我想要的。这是我试图阻止或隐藏它的原因。
试过:
android:descendantFocusability="beforeDescendants"
在片段的主视图上
试过:
android:windowSoftInputMode="stateHidden"
和
android:windowSoftInputMode="stateAlwaysHidden"
在活动清单中
试过:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mViewPager.getChildAt(position).getWindowToken(), 0);
在我的 ViewPager 的 OnPageChangeListener 上
试过:
InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(voucherView.findViewById(R.id.redeem_mobile_number).getWindowToken(), 0);
在我的片段中的 onCreateView
试过:
InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getView().findViewById(R.id.redeem_mobile_number).getWindowToken(), 0);
在我的片段中的 onStart
试过:
voucherView.findViewById(R.id.redeem_mobile_number).clearFocus();
在我的片段中的 onCreateView
在我看来, onPageChangeListener 是这样做的地方,因为其他调用发生在软键盘实际打开之前。任何帮助都会很棒。