I have confirm dialog(A) and warning dialog(B).
Dialog A already show on top.
An event come, dialog B will show on.
I want dialog B will show below dialog A.
Is it possible?
Related
Is it possible to achieve this in Kotlin Android studio.
I have two alert dialog
Dialog one shows on one event to notify users that the event is loading.
Dialog 2 shows when the first event finish loading.
The current results, if dialog one shows, within 2 seconds the activity finish loading and then shows dialog 2.
How can I hide dialog one, on condition of when dialog 2 shows?
This is my alert dialog code
AlertDialog.Builder(requireActivity())
.setTitle("Status upload")
.setMessage("Your image was successfully uploaded!") // Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
.setPositiveButton(android.R.string.yes) { dialog, which ->
// Continue with delete operation
} // A null listener allows the button to dismiss the dialog and take no further action.
.setIcon(R.drawable.ic_check_success)
.show()
you can do this where the event ends
dialog1.dismiss()
I have an Alert Dialog of type TYPE_SYSTEM_ALERT with 2 buttons Ok & Cancel. The OK button opens a new activity where the Cancel button just dismisses the dialog.
The alert it's being displayed 2 times one on top on the other - and if the Cancel button is pressed for the visible dialog - it's being dismissed and the second one it's being displayed and everything works as it should.
My problem is when selecting OK from the visible dialog - the required activity is being opened, the current dialog is being dismissed but a weird thing is happening - the activity is displayed beneath the first dialog and when trying to select one of the buttons the message error "Dropping event due to no window focus: MotionEvent" is displayed - and the dialog can not be accessed anymore.
I've tried with an event to request focus for the remaining Alert - something like:
this.mAlertDialog.getWindow().getDecorView().setFocusable(true);
this.mAlertDialog.getWindow().getDecorView().setFocusableInTouchMode(true);
this.mAlertDialog.getWindow().getDecorView().requestFocus();
or
this.mAlertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).requestFocus();
but no change.
Try one of these
this.mAlertDialog.getWindow().getDecorView().setCancelable(true);
OR
this.mAlertDialog.setCancelable(true);
OR
...onclick(View v) {
this.mAlertDialog.cancel();
}
OR
...onclick(View v) {
this.mAlertDialog.dimiss();
}
My application has a button that shows a custom DialogFragment when the user presses a button. The DialogFragment is shown like this:
if(searchDialog == null)
{
searchDialog = new SearchElementDialog();
searchDialog.setOnItemClickListener(searchElementItemClickListener);
}
searchDialog.show (getFragmentManager(), "SearchElement");
When the user is finished dismiss is called in the usual way and the dialog is removed. Now, when the user presses the same button again I want to show the same dialog, in the same visible state as when the user left it, calling the code in the first block above does display the dialog and its visual state is restored, but:
The screen is not dimmed, and pressing outside of the dialog does not dismiss it and neither are the controls behind it responding.
The dialog does not move when the softkeyboard comes into view.
On the first showing everything is fine. Is it not possible to show the same instance of a dialog again?
What if you hide and show the dialog instead of the whole fragment.
When you want to dismiss call:
searchDialog.getDialog().dismiss();
and when you want to show it:
searchDialog.getDialog().show();
Simas was partly right. getDialog() doesn't return null when the Dialog is shown but it does when there is no Dialog displayed. I stored it as a field in my class
mDialog = getDialog()
and subsequently called
mDialog.show()
which worked every time.
In my android app i am trying to click a button which does some calculation result a alert dialog. asking user yes or not.
Clicking yes perform the action and No dismiss the alert dialog.
Problem is when i am clicking the button very fast it opens two alert box some times , pressing yes in first alert dialog does its action but pressing yes on second result in crash.
What will be the best approach to solve this problem . Actually this is simple subjective logic that's why i am not adding code here .
Simply add:
if(dialog != null && !dialog.isShowing()) {
dialog.show();
}
To your onClick() method. This checks to see if the dialog is showing or not, and only shows it if it isn't already visible.
You'll have to replace dialog with whatever your instance is called.
In my application i need to send some information to server.
This action take time - and i want to show some 'waiting sign' in the meanwhile.
In the main Activity i dont have any place to add progess bar that will show the 'waiting' - so i want to pop up something like dialog box that will show the waiting process.
How to pop up / create this dialog box ( light box ) ?
You can display a Progress Dialog
Here's how you can do it -> http://android-er.blogspot.com/2011/07/display-indeterminate-progress-bar-on.html
mydialog = new Dialog(SplashScreen.this,
R.style.Theme_Transparent);
mydialog.addContentView(new ProgressBar(SplashScreen.this),
new LayoutParams(40, 40));
mydialog.show();
code to show dialog. and mydialog.dismiss() for dismiss dialog.