[英]How to make EditText view get focus and SoftKeyboard input in Presentation(Duel Screen)?
Presentation
to present different contents between the dual screens.Presentation
在双屏之间呈现不同的内容。EditText
view, the Android device's main screen to present SoftKeyboard and get EditText
view focus to make the input.EditText
视图,Android 设备的主屏幕呈现 SoftKeyboard 并获得EditText
视图焦点以进行输入。 I try to use EditText.requestFocus()
and InputMethodManager
to open SoftKeyboard.我尝试使用
EditText.requestFocus()
和InputMethodManager
打开 SoftKeyboard。
PS: Do not tell me to use onKeyDown
listener and TextView.append()
PS:不要告诉我使用
onKeyDown
监听器和TextView.append()
public class MainPresentationFragment extends PresentationFragment {
private EditText textView3;
public MainPresentationFragment() {}
public static MainPresentationFragment newInstance(Context context, Display display){
MainPresentationFragment mainPresentationFragment = new MainPresentationFragment();
mainPresentationFragment.setDisplay(context, display);
return mainPresentationFragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
textView3 = rootView.findViewById(R.id.editText3);
textView3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
textView3.requestFocus();
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
}
return rootView;
}
SoftKeyboard can present on the main screen, but EditText
cannot get input. SoftKeyboard 可以显示在主屏幕上,但
EditText
无法输入。
SoftKeyboard can present on the main screen, but EditText cannot get input.
SoftKeyboard 可以显示在主屏幕上,但 EditText 无法输入。
Correct.正确的。
Presentation
is output-only. Presentation
仅用于输出。 There is no input.没有输入。
My Plan is to making the external display to present an EditText view, the Android device's main screen to present SoftKeyboard and get EditText view focus to make the input.
我的计划是让外部显示器呈现 EditText 视图,Android 设备的主屏幕呈现 SoftKeyboard 并获得 EditText 视图焦点以进行输入。
You should be able to get something like that if:如果出现以下情况,您应该能够得到类似的结果:
EditText
on the device's main screenEditText
放在设备的主屏幕上EditText
to the Presentation
, such as via my MirroringFrameLayout
and Mirror
classesEditText
镜像到Presentation
,例如通过我的MirroringFrameLayout
和Mirror
类Alternatively, you would need to use something like a TextWatcher
on the main screen's EditText
and duplicate the entered text onto the Presentation
's EditText
.或者,您需要在主屏幕的
EditText
上使用类似TextWatcher
东西,并将输入的文本复制到Presentation
的EditText
。 This would be akin to the "onKeyDown listener and TextView.append()" approach that you seem to dislike.这类似于您似乎不喜欢的“onKeyDown 侦听器和 TextView.append()”方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.