当我的片段开始时 - 我想让keybaord消失!
我试试这个(不行......)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_behavior, container, false);
//
if (view.requestFocus()) {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(view, InputMethodManager.imm.showSoftInput(view, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
我也尝试定义
<activity android:name="com.your.package.ActivityName"
android:windowSoftInputMode="stateHidden" />
但也行不通
请...任何帮助:(
由于
答案 0 :(得分:1)
getActivity().getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
答案 1 :(得分:1)
在 onCreateView()
中尝试此代码try {
InputMethodManager input = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
input.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), 0);
}catch(Exception e) {
e.printStackTrace();
}
答案 2 :(得分:1)
/***Just try the below code Snipet***/
Inside your onCreateView of Fragment
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
And put the below piece of code inside your Main Fragment activity tag in manifest file
android:windowSoftInputMode="stateVisible|adjustResize"