我有Fragment
(兼容版本)與其EditText
在其佈局。我正在使用ViewFlipper
在片段之間翻轉。當我到達這個特定Fragment
時,軟鍵盤會自動打開。這不是我想要的。這是我試圖阻止或隱藏它的原因。EditText自動打開軟鍵盤時使用ViewPager可見碎片
嘗試:
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是做這個的地方,因爲其他電話前軟發生鍵盤實際上是打開的。任何幫助都會很棒。
要隱藏片段在try鍵盤: InputMethodManager IMM =(InputMethodManager)getSherlockActivity()getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(inputSearch.getWindowToken(),0); P.S inputSearch是EditText字段 –