I want to keep AlertDialog focused until a user presses any of the buttons on it. In other words, even if a user presses any other area (like it's parent area) or presses back button, dialog must still remain focused. Please let me know which Android 4.0 API method to use.
Thanks much in advance.
use setCancelable(false); It will stop removing your AlertDialog from your screen.
Related
I'm trying to display an activity with a button that covers a portion of the screen similar to a dialog.
This was almost working as I wanted it by using #android:style/android:Theme.Holo.Panel. It wasn't quite what I wanted however as I want the background to be dimmed with the activity is displayed. So I switched to this style instead: #android:style/android:Theme.Holo.Dialog.NoActionBar.
Now this looks like I want it and the background is dimmed. BUT the problem with this is if the user touches anywhere on the screen apart from the dialog then the activity gets dismissed. This does't happen with the Panel theme, the user can only dismiss it by pressing on the button.
How can I prevent the activity from being dismissed on any touch event with the Theme.Holo.Dialog?
Have you tried this.setFinishOnTouchOutside(false); ?
This being your activity.
I know this should not be a big challenge but it really drives me insane.
I am developing a simple soft keyboard input method and basically I have added a button to my softkeyboard, by pressing which, a dialog should pop up to prompt user to do some choices.
By far everything is ok about creating and opening the dialog. Since normally a dialog is created and displayed from outside an activity, so a flick solution could be to create a transparent activity which embedded the dialog in it. By doing so, I could easily start a dialog when user click the button on my softkeyboard.
But one tricky problem is: every time user click the button and the dialog (actually a dialog in a transparent activity) displays, it will always make my softkeyboard hide. I just need to start the dialog without any changes to the status of my softkeyboard -- I want my softkeyboard keeps showing when the dialog starts.
Here is a snapshot of Google Keyboard, it has the similar button which display a dialog and the dialog did not hide the keyboard, this is exactly what I want. So please anyone suggest me how to achieve this. Thanks so much.
THey aren't launching an Activity. They're launching a dialog. Which is tricky from an input method because its a service (you have to specify the dialog's window token to make it show) but doable.
In an android application, I want to display a Dialog on screen and in the same time to allow user to click on the application's UI when the the Dialog is open
can this be done?
if no, what can I use instead of Dialog?
I don't think you can do this with Dialog. But you can do it with PopupWindow using PopupWindow.setOutsideTouchable(true);.
Showing up a dialog over your Activity, will make your Activity go into onPause() so you won't be able to actually handle things inside that activity anymore until the dialog is dismissed.
If you want to have some view, overlay your original activities view you'll be looking for into the direction of FrameViews, which can overlap other Views.
I show a Dialog box to the user while loading a page.Would there be any problem if i show another Dialog box before dismissing the previous one?
I have tested it and its working fine.Just wanted to make sure.
I need to do this because-- When the user clicks on a button i show loading dialog box and users identity is verified in the background.If i dismiss this dialog box there the lag of say 2 sec( specially when network is very slow),before the user moves to the next activity.
I am showing another dialog box so that the user stays in that activity before all background work is done.
There would be no problem, when you are displaying one or two dialog boxes, but If you increase the number of dialog boxes, then your application becomes complex for users and it don't meet the user-friendly principles. you can use more dialog boxes in different places in your app.If you try to show more than three or four dialog continously, then your application will not meet the quality.
My application displays alert dialogs in some cases. Also, it is possible for a user to launch my application using the VIEW/SEND intent. The scenario I am considering is, the dialog is visible, the user presses 'Home' & selects my application to View/Share a file.
I would want to dismiss the dialog before beginning with the view/share operation. Although I can maintain which dialog is visible and hide it before the operation begins, I was wondering if there is a conventional/recommended way or API, something like activity.dismissAnyVisibleDialog() that can come in handy.
Thanks a lot,
Akshay
I finally myself maintained which dialog is visible & dismissed it before displaying the next one.
-Akshay
Just close the dialog in the onPause() method (override in your activity).
This way it will be dismissed when the activity is no longer visible i.e if you switch to the home screen.