Reputation: 373
I have a problem.
I made custom Dialog
(loading spinner).
I touching down the Button
. Then opens RelativeLayout
with table and edit text which works like search.
My problem is that when i show loader between button touch and opening Layout it focuses on EditText
but doesn't show keyboard. When i don't use my dialog, it works fine. I tried it on foreground and in thread - the same result.
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.
Upvotes: 0
Views: 88
Reputation: 373
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);
Upvotes: 0
Reputation: 211
in 'loader.show()' you can try this code to show keyboard:
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);
}
});
Upvotes: 1