[英]Doesn't show Keyboard when requesting EditText after Dialog
I have a problem. 我有个问题。
I made custom Dialog
(loading spinner). 我制作了自定义
Dialog
(正在加载微调器)。 I touching down the Button
. 我按下
Button
。 Then opens RelativeLayout
with table and edit text which works like search. 然后使用表格打开
RelativeLayout
并编辑类似于搜索的文本。
My problem is that when i show loader between button touch and opening Layout it focuses on EditText
but doesn't show keyboard. 我的问题是,当我在按钮触摸和打开Layout之间显示加载程序时,它专注于
EditText
但不显示键盘。 When i don't use my dialog, it works fine. 当我不使用对话框时,效果很好。 I tried it on foreground and in thread - the same result.
我在前台和线程中尝试过-同样的结果。
XML : XML :
<ProgressBar
android:layout_width="100dp"
android:layout_height="100dp"
android:indeterminateOnly="false"
android:id="@+id/loader_spiner"
android:background = "@xml/progress"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
Code : 代码 :
public void prepareLoader(){
loader = new Dialog(context);
loader.setContentView(R.layout.ag_loader);
loader.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
spinerLoader = (ProgressBar) loader.findViewById(R.id.loader_spiner);
}
public void showLoader(){
spinerLoader.startAnimation(AnimationUtils.loadAnimation(this, R.xml.splash_spinner));
loader.show();
}
public static void hideLoader(){
loader.hide();
}
Thanks a lot. 非常感谢。
in 'loader.show()' you can try this code to show keyboard: 在“ loader.show()”中,您可以尝试以下代码来显示键盘:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
or: 要么:
loader.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
or: 要么:
loader.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
or if not work again try it: 或者,如果无法再次尝试,请尝试:
Handler delayedRun = new Handler();
delayedRun.post(new Runnable() {
@Override
public void run() {
youreditText.requestFocus();
InputMethodManager mgr = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(youreditText, InputMethodManager.SHOW_IMPLICIT);
}
});
I found a solution with getting some time for keyboard to appear. 我找到了一种解决方法,可以花一些时间让键盘出现。
new android.os.Handler().postDelayed(
new Runnable() {
public void run() {
if (thisSearchable) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(searchInput, InputMethodManager.SHOW_IMPLICIT);
}
}
}, 300);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.