在横向模式下DialogFragment上的键盘

时间:2014-04-08 15:00:59

标签: android android-softkeyboard android-dialogfragment

在我的应用程序中,当单击一个按钮时,会出现dialogfragment,然后显示软键盘,然后如果我更改了方向,则始终显示键盘。但是,如果我在午餐应用程序在第一键盘上的应用程序没有出现。知道键盘没有显示的原因吗?

public class PlateDialogFragment extends DialogFragment {

static View view;
public static PlateDialogFragment newInstance(View v) {
    view=v;
    PlateDialogFragment f = new PlateDialogFragment();
    f.setCancelable(false);
    f.setStyle(STYLE_NO_FRAME, STYLE_NO_TITLE);
    return f;
}

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    return dialog;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_dialog_plate, container, false);
    setRetainInstance(false);
    Button cancel = (Button) v.findViewById(R.id.exit);
    cancel.setOnClickListener(cancelDialogListener);
    Button next = (Button) v.findViewById(R.id.next);
    next.setOnClickListener(nextDialogListener);

    plate1 = (EditText) v.findViewById(R.id.plate1);
    plate1.setOnFocusChangeListener(plateFocusChanged);
    plate1.addTextChangedListener(plate1Watcher);
    plate2 = (EditText) v.findViewById(R.id.plate2);
    plate2.setOnFocusChangeListener(plateFocusChanged);
    plate2.addTextChangedListener(plate2Watcher);
    plate3 = (EditText) v.findViewById(R.id.plate3);
    plate3.setOnFocusChangeListener(plateFocusChanged);
    plate3.addTextChangedListener(plate3Watcher);
    plate3.setOnEditorActionListener(plate3EditorActionListener);
    plate1.requestFocus();
    getDialog().getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return v;
}

@Override
public void onDetach() {
    Log.i("onDetach", "onDetach");
    InputMethodManager inputMethodManager = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(plate1.getWindowToken(), 0);
    super.onDetach();
}

1 个答案:

答案 0 :(得分:0)

我猜这可能是由于全景[所谓的'提取']风景的IME模式 - 因为它会模糊整个用户界面 [这会违反直觉对于用户] ,直到用户点击其中一个输入 [因此确认他们真的希望IME弹出并采取它需要的任何房地产]时才会显示

作为应对此问题的可行方法,请尝试设置

plate1.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);

for eachi EditText或使用相应的

android:imeOptions="flagNoExtractUi"
布局文件中EditText

属性。

相关问题